Jquery ui 使用多分组避免JQGrid中的客户端行排序
我注意到,一旦通过ajax getJSon()检索到值列表,JQGrid中的多重分组会导致行排序以内联方式重新排列。 有时,重新排序会将相同元素的组拆分为多个组,这是应该的 我想解决方案是避免客户端对JQGrid行重新排序,目的是明确地重用JSON中给定的相同顺序,而不改变服务器返回的顺序 我正在使用以下配置:Jquery ui 使用多分组避免JQGrid中的客户端行排序,jquery-ui,jquery,jquery-plugins,jqgrid,Jquery Ui,Jquery,Jquery Plugins,Jqgrid,我注意到,一旦通过ajax getJSon()检索到值列表,JQGrid中的多重分组会导致行排序以内联方式重新排列。 有时,重新排序会将相同元素的组拆分为多个组,这是应该的 我想解决方案是避免客户端对JQGrid行重新排序,目的是明确地重用JSON中给定的相同顺序,而不改变服务器返回的顺序 我正在使用以下配置: jq("#myGrid").jqGrid({ datatype: 'local', data: myvar.detail, // a well formatted json l
jq("#myGrid").jqGrid({
datatype: 'local',
data: myvar.detail, // a well formatted json locally stored
colNames: [ ....],
colModel: [
{name:'nome_attr',index:'nome_attr', sorttype: function () {return 1;}, editable:true, editrules:{required:true}, editoptions:{size:27}, align:'center'},
{name:'desc_attr', index:'desc_attr', sorttype: function () {return 1;}, editable:true, editrules:{required:false}, edittype: "textarea",editoptions:{rows:5, cols:25}, hidden:true},
{name:'valore',index:'valore', sorttype: function () {return 1;},editable:true, editrules:{required:false}, editoptions:{size:30}, width:120},
....
],
loadonce: false, // to dis-able sorting on client side
sortable: false,
grouping:true,
groupingView : {
groupField : ['nome_attr', 'valore'],
groupColumnShow: [false,false],
groupText : ['{0}'],
groupCollapse: true,
groupDataSorted: false,
groupSorted: false,
groupOrder: false
}
});
注意(1)我已经在使用解决方法来禁用排序类型
sorttype: function () {return 1;}
如前所述,在中,“#myGrid”
是一个子网格,其中数据类型:local
,表示先前已在容器网格中检索到行
是否有人知道要设置的colModel
属性和groupingView
参数的配置是什么,以避免在多分组的情况下进行在线重新排序
提前感谢,
Michele修复自动排序的一个解决方法是允许客户端工作,以便重新生成相同的值列表(重新创建相同的顺序) 首先,准备一个JScript函数,强制为每个分组的列指定正确的顺序值:
/**
* Sort type in subgrid's gropued rows
*/
function sortGroup(cellValus, rowData, ty) {
if(ty==='attribute_1')
return rowData.attr1_order;
else if(ty==='attribute_2')
return rowData.attr2_order;
}
其次,在colModel
中注入所需的订单值
第三,在每个分组列中的sorttype
内触发上一个函数,使用列类型了解订单所属的组:
colModel: [
{name:'nome_attr',index:'nome_attr', sorttype: function (cellValus, rowData) {return sortGroup(cellValus, rowData, 'attribute_1')}, editable:true, editrules:{required:true}, editoptions:{size:27}, align:'center'},
{name:'desc_attr', index:'desc_attr', editable:true, editrules:{required:false}, edittype: "textarea",editoptions:{rows:5, cols:25}, hidden:true},
{name:'valore',index:'valore', sorttype: function (cellValus, rowData) {return sortGroup(cellValus, rowData, 'attribute_2')},editable:true, editrules:{required:false}, editoptions:{size:30}, width:120},
.....
{name:'attr1_order',index:'attr1_order', editable:false, hidden:true},
{name:'attr2_order',index:'attr2_order', editable:false, hidden:true}
]