用于分组的jqGrid拖放标题....组名 [英] jqGrid drag and drop headings for grouping .... Group Name
问题描述
我已经设置了拖放标题,以按 jQgrid分组拖放的相关列进行分组
I have setup drag and drop headings to group by the relevant column from jQgrid Grouping Drag and Drop
效果很好,但是我试图在值之前显示列名.
It works great however I am trying to display the column name before the value i.e.
Client : Test data data
Client : Test2 data data
如果有人可以帮助我,我一直在兜圈子.
如果我采用用于动态组的相同代码,则应将其作为(列名称)
我最后得到的是列"数据而不是列名.
I've been going around in circles if any one could help.
if i take the same code used for the dynamic group by which should be the (column Name)
I end up with The Column data not the column name.
$('#' + gridId).jqGrid('groupingGroupBy', getheader());
function getheader() {
var header = $('#groups ol li:not(.placeholder)').map(function () {
return $(this).attr('data-column');
}).get();
return header;
}
如果我在组文本中使用相同的功能,我会得到数据而不是列名.
if i use the same function in group text I get data not the column name.
我来自C#,并且对jQuery非常陌生.
I've come from C# and I am very new to jQuery.
如果有任何帮助,将不胜感激.
If any one could help it would be greatly appreciated.
亲切的问候,
瑞安
Kind Regards,
Ryan
推荐答案
首先更新的演示为您的问题提供解决方案:
First of all the updated demo provides the solution of your problem:
另一个演示包含简化的演示,演示了如何实现在分组标题中以Column Header: Column data
形式显示分组标题,而不是默认使用Column data
.
Another demo contains simplified demo which demonstrates just how one could display the grouping header in the form Column Header: Column data
in the grouping header instead of Column data
used as default.
该解决方案的主要思想是使用groupingView
的formatDisplayField
属性,该属性最初是我在答案中提出的.一个>.当前版本的jqGrid支持该选项.例如,如果要使用选项
The main idea of the solution is the usage of formatDisplayField
property of groupingView
which I suggested originally in the answer. The current version of jqGrid support the option. If one would use for example the options
grouping: true,
groupingView: {
groupField: ["name", "invdate"],
groupColumnShow: [false, false],
formatDisplayField: [
customFormatDisplayField,
customFormatDisplayField
]
}
其中customFormatDisplayField
回调函数定义为
var customFormatDisplayField = function (displayValue, value, colModel) {
return colModel.name + ": " + displayValue;
}
将几乎显示您需要的结果,但是它将使用colModel
的name
属性,而不是colNames
中的相应名称.为了提供最终解决方案,请使用customFormatDisplayField
的另一种实现:
will display almost the results which you need, but it will uses name
property of colModel
instead of the corresponding name from colNames
. To makes the final solution one use another implementation of customFormatDisplayField
:
var getColumnHeaderByName = function (colName) {
var $self = $(this),
colNames = $self.jqGrid("getGridParam", "colNames"),
colModel = $self.jqGrid("getGridParam", "colModel"),
cColumns = colModel.length,
iCol;
for (iCol = 0; iCol < cColumns; iCol++) {
if (colModel[iCol].name === colName) {
return colNames[iCol];
}
}
},
customFormatDisplayField = function (displayValue, value, colModel, index, grp) {
return getColumnHeaderByName.call(this, colModel.name) + ": " + displayValue;
};
这篇关于用于分组的jqGrid拖放标题....组名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!