如何在jqgrid中为不同的行添加不同的下拉列表 [英] How to add different dropdown in jqgrid for different row

查看:114
本文介绍了如何在jqgrid中为不同的行添加不同的下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I want to add a dropdown in column4 of jqgrid and bind the data for it based on its Column2 particular cell value. All I need is dropdown data will be different for each cell in a Column and it depends on the column2 cell value of that particular row.

$("#VendorGrid").jqGrid({
                url: 'TRPurchase.aspx/VendorDATA',
                datatype: 'json',
                mtype: 'POST',

                serializeGridData: function (postData) {
                    return JSON.stringify(postData);
                },

                ajaxGridOptions: { contentType: "application/json" },
                loadonce: true,
                colNames: ['ID', 'Inventory ID', 'Company Name', ' ModelNumber'],
                colModel: [

                                  { name: 'ID', index: 'ID' },
                                { name: ' InventoryID', index: ' InventoryID ' },
                                { name: 'strCompanyName', index: 'strCompanyName' },
                                {
                                           name: 'ModelNumber', index: 'ModelNumber',
                                           sortable: true,
                                           align: 'center',
                                           editable: true,
                                           cellEdit: true,
                                           edittype: 'select',
                                           formatter: 'select',
                                           //beforeSaveCell: function(value) {
                                           //    alert('New cell value: "'+value+'"');
                                           //},
                                           editoptions: {
                                               value: getAllSelectOptions(),
                                               dataEvents: [
                                                     {
                                                         type: 'change',
                                                         fn: function () {
                                                             debugger;
                                                            
                                                         }
                                                     }]
                                           }
                                       },				],
		pager: '#pagingGrid',
                rowNum: 10,
                rowList: [10, 20, 30],
                viewrecords: true,
                gridview: true,
});
Here is my jqgrid code. In column4 'ModelNumber'  editoptions function of column call a function getAllSelectOptions() and it returns all data from the array which came from the Ajax call (Ajax call only once while grid load) and bind it for all cells of a column.  I want to bind data in column4 depends on the cell value of column2 ' InventoryID'.

For server side I am using ASP.NET with C#.





我尝试了什么:



我尝试用两种方式做到这一点,一种是jqgrid的dataurl属性但是它无法正常实现我的要求。另一个是在jqgrid的selectcellEvent上我每次当用户选择特定的下拉单元格列时都试图调用Ajax但是在这种情况下单元格进入可编辑模式并且Ajax花费时间返回数据无法将数据显示为可编辑模式。



What I have tried:

I tried to do it with two ways one is dataurl properties of jqgrid but it does not work properly to achieve my requirement. The other is on selectcellEvent of jqgrid I tried to call Ajax each time when user select particular dropdown cell column but in this case cell get into editable mode and Ajax take time to return data can’t show data into editable mode.

推荐答案

#VendorGrid)。jqGrid( {
url:' TRPurchase.aspx / VendorDATA'
datatype:< span class =code-string>' json'
mtype:' POST'

serializeGridData: function (postData){
return JSON .stringify(postData);
},

ajaxGri dOptions:{contentType: application / json},
loadonce: true
colNames:[' ID'' 库存ID'' < span class =code-string>公司名称',' ModelNumber'],
colModel:[

{name:' ID', index:' ID'},
{name:' InventoryID',index:' InventoryID'},
{name:' strCompanyName',index:' strCompanyName'},
{
name:' ModelNumber',index:' ModelNumber'
sortable: true
align:' center'
可编辑: true
cellEdit: true
edittype:' select'
formatter:' select'
// beforeSaveCell:function(value){
// alert('新单元格值:'+ value +'');
// },
editoptions:{
value:getAllSelectOptions(),
dataEvents:[
{
type:' 更改'
fn: function (){
debugger < /跨度>;

}
}]
}
},],
寻呼机:' < span class =code-string>#pagingGrid'

rowNum: 10
rowList:[ 10 20 30 ],
viewrecords : true
gridview: true
});
这是我的jqgrid代码。在column4中' ModelNumber' editoptions function of column调用 function getAllSelectOptions(),它返回来自Ajax调用的数组中的所有数据(Ajax调用只有一次网格加载)并绑定 列的所有单元格。我想绑定数据 column4中取决于column2的单元格值' InventoryID'

对于服务器端,我使用ASP.NET C#。
("#VendorGrid").jqGrid({ url: 'TRPurchase.aspx/VendorDATA', datatype: 'json', mtype: 'POST', serializeGridData: function (postData) { return JSON.stringify(postData); }, ajaxGridOptions: { contentType: "application/json" }, loadonce: true, colNames: ['ID', 'Inventory ID', 'Company Name', ' ModelNumber'], colModel: [ { name: 'ID', index: 'ID' }, { name: ' InventoryID', index: ' InventoryID ' }, { name: 'strCompanyName', index: 'strCompanyName' }, { name: 'ModelNumber', index: 'ModelNumber', sortable: true, align: 'center', editable: true, cell true, edittype: 'select', formatter: 'select', //beforeSaveCell: function(value) { // alert('New cell value: "'+value+'"'); //}, editoptions: { value: getAllSelectOptions(), dataEvents: [ { type: 'change', fn: function () { debugger; } }] } }, ], pager: '#pagingGrid', rowNum: 10, rowList: [10, 20, 30], viewrecords: true, gridview: true, }); Here is my jqgrid code. In column4 'ModelNumber' editoptions function of column call a function getAllSelectOptions() and it returns all data from the array which came from the Ajax call (Ajax call only once while grid load) and bind it for all cells of a column. I want to bind data in column4 depends on the cell value of column2 ' InventoryID'. For server side I am using ASP.NET with C#.





我尝试了什么:



我尝试用两种方式做到这一点,一种是jqgrid的dataurl属性但是它无法正常实现我的要求。另一个是在jqgrid的selectcellEvent上我每当用户选择特定的下拉单元格列时都试图调用Ajax,但在这种情况下,单元格进入可编辑模式,而Ajax需要时间来返回数据,无法将数据显示为可编辑模式。



What I have tried:

I tried to do it with two ways one is dataurl properties of jqgrid but it does not work properly to achieve my requirement. The other is on selectcellEvent of jqgrid I tried to call Ajax each time when user select particular dropdown cell column but in this case cell get into editable mode and Ajax take time to return data can’t show data into editable mode.


这篇关于如何在jqgrid中为不同的行添加不同的下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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