JQGrid创建下拉单元格,其值取自行ID

时间:2012-03-21 15:27:48

标签: jqgrid-asp.net

我有以下JQgrid工作正常。

                $("#Groups_UseCases_Grid").jqGrid({
                    url: 'groupsHandler.ashx?mod=3',
                    datatype: 'json',
                    mtype: 'GET',                 
                    loadonce: true,
                    height: 'auto',

                    width:'750px',
                    colNames: ['id', 'groupname', 'workSpace'],
                    colModel: [
                            { name: 'id', index: 'id', key:true, width: 200, sortable: false,  editoptions: {readonly: true,size: 10}},
                            { name: 'groupname', width: 200, sortable: false, editable:false },
                            { name: 'workSpace', width: 400, sortable: false, editable:true , edittype:"select",editoptions:{multiple:true, size:"<%=combolistSize%>", value:"<%=combolist%>"} }                             
                              ],                                              
                    rowNum: 30,
                    rowList: [30, 60, 90],
                    pager: '#pager',                
                    sortname: 'id',
                    viewrecords: true,
                    sortorder: 'asc',
                    caption: 'Groups UseCases Ascosiation Grid', 
                    editurl: 'groupsHandler.ashx?mod=3', 
                    hidegrid: false,
                    altRows:false,                 
                    altclass:'myAltRowClass',                    

                    grouping:true,
                    groupingView : {
                    groupField : ['useCase'],
                    groupText : ['<b> useCase : {0}  (Records {1}) </b>']

                }
                });             

                 jQuery("#Groups_UseCases_Grid").jqGrid('navGrid',"#pager",
                    {edit:false,add:false,del:false});  
                jQuery("#Groups_UseCases_Grid").jqGrid('inlineNav',"#pager", 
                  {edit:true,add:false,del:false},
                   {afterSubmit: function(rowid, aData){document.forms[1].submit();//alert("row id is "+rowid)
                        }},   
                        {closeAfterEdit: true,reloadAfterSubmit: false},
                        {closeAfterAdd: true,reloadAfterSubmit: false},

                        {reloadAfterSubmit: true});                           

C# code : private string combolist; protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) {
combolist =create_combolist();
}
}
private string create_combolist(/string groupID/) {.....}


我的问题是我希望通过给出所选行的id来生成列workSpace值,因为它取决于它并缩小了下拉值列表 是否可以使用onSelectRow? 我试过了 onSelectRow: function(id){<%usecasesample.create_combolist(); <%combolist = usecasesample.create_combolist();%>; } , 这也有效,但我不能在其中提供行ID。

任何帮助表示感谢,提前感谢, 亚历

1 个答案:

答案 0 :(得分:0)

这似乎工作正常

        $("#Groups_UseCases_Grid").jqGrid({
                        url: 'groupsHandler.ashx?mod=2',
                        datatype: 'json',
                        mtype: 'GET',                 
                        loadonce: true,
                        height: 'auto',

                        width:'850px',
                        colNames: ['groupid', 'groupname', 'workspaces'],
                        colModel: [
                                { name: 'groupid', index: 'id', key:true, width: 200, sortable: false,  editoptions: {readonly: true,size: 10}},
                                { name: 'groupname',index: 'groupname', width: 200, sortable: false, editable:false },
                                { name: 'workspaces', width: 400, sortable: false, editable:true , edittype:"select",editoptions:{multiple:true, size:"" }}


                                  ],                                                                      
                        
                         onSelectRow: function(id) {                          
                            var name='workspaces';                                 
                            jQuery("#Groups_UseCases_Grid").setColProp(name, { editoptions: {multiple:true,  dataUrl: 'groupsHandler.ashx?mod=3&rowID='+id }})                                    

                        },

                        
                        rowNum: 30,
                         cellEdit:false,
                        rowList: [30, 60, 90],
                        pager: '#pager',                
                        sortname: 'id',
                        viewrecords: true,
                        sortorder: 'asc',
                        caption: 'Groups UseCases Ascosiation Grid', 
                        editurl: 'groupsHandler.ashx?mod=2&rows=20&page=1', 
                        hidegrid: false,
                        altRows:false,                 
                        altclass:'myAltRowClass',                    

                        grouping:true,
                        groupingView : {
                        groupField : ['useCase'],
                        groupText : [' useCase : {0}  (Records {1}) ']

                    }
                    });             

                     jQuery("#Groups_UseCases_Grid").jqGrid('navGrid',"#pager",
                        {edit:false,add:false,del:false});  
                    jQuery("#Groups_UseCases_Grid").jqGrid('inlineNav',"#pager", 
                      {edit:true,add:false,del:false},
                       {afterSubmit: function(rowid, aData){document.forms[1].submit();//alert("row id is "+rowid)
                            }},   
                            {closeAfterEdit: true,reloadAfterSubmit: false},
                            {closeAfterAdd: true,reloadAfterSubmit: false},
                            {reloadAfterSubmit: true});