【问题标题】:Using jqGrid, Is there anyway to have dynamic dropdown in the edit record popup?使用jqGrid,在编辑记录弹出窗口中是否有动态下拉菜单?
【发布时间】:2012-08-30 14:16:49
【问题描述】:

我有一个包含三个字段的记录,它们都是下拉列表。如果它们是独立的记录,这一切都很好,但是我希望如果您更改第一个下拉列表,那么第二个下拉列表中的项目列表会更改吗?这在 jqgrid 中是否可行。

我的代码的简化版本现在看起来像这样:

jQuery("#marketDataGrid").jqGrid({
    mtype: "POST",
    url: "/Application/MarketData/" + id,
    datatype: "json",
    colNames: ["", "Id","Source", "API"],
    colModel: [
        { name: "ApplicationId", index: "ApplicationId", hidden: true, width: 0, editable: true, editoptions: { readonly: true} },
        { name: "Id", index: "Id", hidden: false, width: 30, editable: false, editoptions: { readonly: true} },
        { name: "MarketDataSource", index: "MarketDataSource", editoptions: { dataUrl: "/MarketDataSource/GetSelectDataRequired" }, editrules: { required: true }, editable: true, edittype: "select", width: 155, stype: 'select', searchoptions: { sopt: ['eq', 'ne'], dataUrl: "/MarketDataSource/GetSelectData"} },
        { name: "API", index: "API", editoptions: { dataUrl: "/API/GetSelectDataRequired" }, editrules: { required: true }, editable: true, edittype: "select", width: 155, stype: 'select', searchoptions: { sopt: ['eq', 'ne'], dataUrl: "/API/GetSelectData"} }

    ],

【问题讨论】:

  • 我想你想要这样的东西ok-soft-gmbh.com/jqGrid/DependendSelects1.htm
  • 双击任一行的国家列,改变值,状态值得到改变
  • @PiyushSardana - 谢谢。 .我试图这样做不是在网格中内联,而是在弹出编辑表单上。类似的事情可能吗?
  • 我相信它也适用于表单编辑。

标签: jquery jqgrid


【解决方案1】:

在 jqGrid 中没有简单的方法来实现依赖选择。尽管如此,我在the answerthe demo 中展示了如何实现依赖选择。我在树案例中演示了实现:内联编辑、表单编辑和搜索工具栏。

在您的情况下,您使用editoptions 中的dataUrl 而不是参考演示中使用的value。然而,实现可以基于相同的想法。您可以为“主”选择注册change 事件并向服务器发出$.ajax 请求以获取从属选择的选择选项的子集。在success$.ajax 句柄内部,您将能够执行与我的演示中相同的操作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-03-05
    • 1970-01-01
    • 2014-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多