使用jqGrid,在编辑记录弹出窗口中是否总有动态下拉菜单? [英] Using jqGrid, Is there anyway to have dynamic dropdown in the edit record popup?

查看:72
本文介绍了使用jqGrid,在编辑记录弹出窗口中是否总有动态下拉菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含三个字段的记录,它们都是下拉列表.如果它们是独立记录,那么一切正常,但是我想在哪里更改第一个下拉列表,然后第二个下拉列表中的项目列表更改?在jqgrid中有可能吗?

I have a record that has three fields and they are all dropdowns. It all works fine if they are independent records but i would like it where if you change the first dropdown, then the list of items in the second dropdown changes? Is this possible in jqgrid.

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

Simplified version of my code looks like this now:

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"} }

    ],

推荐答案

在jqGrid中没有实现依赖选择的简单方法.不过,我在演示中进行了展示: //stackoverflow.com/a/4480184/315935>答案如何实现依存选择.我在树状案例中演示了该实现:内联编辑,表单编辑和搜索工具栏.

There are no simple way to implement dependent selects in jqGrid. Nevertheless I shown in the demo from the answer how dependent selects could be implemented. I demonstrated the implementation in tree cases: inline editing, form editing and searching toolbar.

在您的情况下,请使用editoptionsdataUrl而不是引用的演示中使用的value.然而,该实现可以基于相同的想法.您可以为主要"选择注册change事件,并向服务器发出$.ajax请求,以获取从属选择的选择选项的子集.在$.ajaxsuccess手柄内部,您将能够执行与演示中相同的操作.

In your case you use dataUrl of editoptions instead of value used in the referenced demo. Nevertheless the implementation can be based on the same idea. You can register change event for the "main" select and make $.ajax request to the server to get the subset of select's options of the dependent select. Inside of success handle of $.ajax you will be able to do the same thing like in my demo.

这篇关于使用jqGrid,在编辑记录弹出窗口中是否总有动态下拉菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆