我是flexigrid的新手.任何人都可以让我知道如何获取每列所选行的值.
如何获取每个列名称(reportName和reportDescription)?因为我推送//将所有数据推送到数组中,如下所述.
我使用下面的代码来获取选定的行.但它返回null.你可以帮我一下吗?
//Column. <br/>
colModel: [
{ display: 'WidgetID', name: 'WidgetID', width: 50, sortable: true, align: 'left', hide: true },
{ display: 'Widget Name', name: 'WidgetName', width: 170, sortable: true, align: 'left' },
{ display: 'IsClientReport', name: 'IsClientReport', width: 50, sortable: false, align: 'left', hide: true },
{ display: 'ClientReportID', name: 'ClientReportID', width: 50, sortable: false, align: 'left', hide: true },
{ display: 'ReportType', name: 'ReportType', width: 280, sortable: true, align: 'left' }
],
$('#grid01').click(function(event){
$('.trSelected', this).each( function(){
console.log( ' rowId: ' + $(this).attr('id').substr(3) + ' IsClientReport: ' + $('td[abbr="IsClientReport"] >div', this).html() + ' sign: ' + $('td[abbr="WidgetID"] >div', this).html() + ' ReportType: ' + $('td[abbr="ReportType"] >div', this).html() );
});
});
Run Code Online (Sandbox Code Playgroud)
谢谢,Pon Kumar Pandian
不确定你是否已经弄明白了,但我会在这里留下这个答案,以防其他同样情况的人在我的问题上遇到问题.
在列上设置'sortable:false'会从Flexigrid生成的'td'中删除'abbr'属性.这意味着您无法使用推荐的解决方案来获取所选行.
我自己修改了flexigrid.js文件来解决这个问题.
如果列具有"名称"并且具有"sortable:true",则Flexigrid以前仅添加了'abbr'属性.我删除了'sortable:true'的条件.
反过来,这也意味着列总是可以排序的.为了防止这种情况,我添加了一个'sortable'属性,只有当列是'sortable:true'时才会设置
在那之后,我不得不经历并找到所有使用'abbr'作为排序条件的情况,并用"可排序"检查替换它.
而已.
如果您只想下载并使用此文件,我会将文件上传到mediafire.在非特定的地方有一些太多的变化,我在这里显示我的代码更改.如果需要,我可以提供差异或更多的解释.请注意,'sortable:true'仍适用于我的修复程序.