jquery - 在 JQXGrid 的 dataAdapter 中获取过滤后的数据

标签 jquery html asp.net-mvc jqxgrid

我在我的应用程序中使用了 JQXGrid。在初始加载中,数据从服务器检索并加载到 dataAdapter 中,dataAdapter 用作网格的源。当我过滤网格中的任何列时,我需要在 dataAdapter 中单独拥有那些过滤后的数据。谁能帮帮我。感谢您的帮助。

function loadGrid(data, ref, undo) {
//debugger;
try {
var source =
{
datatype: “json”,
datafields:
[
{ name: 'ProductionResource', type: 'string' },
{ name: 'Series', type: 'string' },
{ name: 'ItemStatus', type: 'string' },
{ name: 'FutureStatus', type: 'string' },
{ name: 'Abc1Code', type: 'string' },
{ name: 'ItemNumber', type: 'string' },
{ name: 'FirmDemands', type: 'number' },
{ name: 'NetForecast', type: 'number' },
{ name: 'PromotionalLift', type: 'number' },
{ name: 'TotalReceipts', type: 'number' },
{ name: 'ItemQuantity', type: 'number' },
],
localdata: data
};
var dataAdapter = new $.jqx.dataAdapter(source);
$(“#mainData”).jqxGrid(
{
width: ’99.5%’,
pageable: false,
height: ’100%’,
rowsheight: 30,
altrows: true,
source: dataAdapter,
groupable: true,
groups: ['Series'],
showgroupsheader: false,
groupsrenderer: function (defaultText, group, state, params) {
//return “<div style=’margin: 5px;’>” + group + “</div>”;
return “<div style=’margin: 5px;’>” + ” + “</div>”;
},
groupsexpandedbydefault: true,
sortable: false,
filterable: true,
//filtermode: ‘excel’,
columnsresize: true,
columnsreorder: true,
editable: true,
selectionmode: ‘multiplecellsadvanced’,
//autoshowfiltericon: false,
showfilterrow: false,
columnmenuopening: function (menu, datafield, height) {
var column = $(“#mainData”).jqxGrid(‘getcolumn’, datafield);
if (column.filtertype === “custom”) {
menu.height(1000);
setTimeout(function () {
menu.find(‘input’).focus();
}, 25);
}
else menu.height(height);
},
columns: [
{ text: ‘Production Resource’, datafield: ‘ProductionResource’, width: ’8.5%’, editable: false, groupable: false },
{ text: ‘Series’, datafield: ‘Series’, width: ’8.5%’, editable: false, groupable: true },
{ text: ‘Item Status’, datafield: ‘ItemStatus’, width: ’8.5%’, editable: false, groupable: false },
{ text: ‘Future Status’, datafield: ‘FutureStatus’, width: ’6%’, editable: false, groupable: false },
{ text: ‘ABC 1 (Tiers)’, datafield: ‘Abc1Code’, width: ’5%’, editable: false, groupable: false },
{ text: ‘Item #’, datafield: ‘ItemNumber’, width: ’8.5%’, editable: false, groupable: false },
{ text: ‘Firm Demands’, datafield: ‘FirmDemands’, width: ’6%’, editable: false, groupable: false },
{ text: ‘Net Forecast’, datafield: ‘NetForecast’, width: ’6%’, editable: false, groupable: false },
{ text: ‘Promotional Lift Qty’, datafield: ‘PromotionalLift’, width: ’8%’, editable: false, groupable: false },
{ text: ‘Total Receipts’, datafield: ‘TotalReceipts’, width: ’6.5%’, editable: false, groupable: false },
} catch (e) {
alert(e.message);
}

最佳答案

我们可以使用以下代码在dataAdapter中获取过滤后的数据。

var rows = $("#mainData").jqxGrid('getrows');
 var dataAdapter = new $.jqx.dataAdapter(source);
 dataAdapter.records = rows;

关于jquery - 在 JQXGrid 的 dataAdapter 中获取过滤后的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42206338/

相关文章:

javascript - 如何通过 JSON GET 请求将输入中的文本附加到单个元素?

javascript - Wordpress 的图像悬停效果

javascript - 如何重复查询?

Javascript POST 到 PHP 页面

javascript - 如何显示 JQPLOT 图而不是长文本

asp.net-mvc - ASP.NET MVC 框架中的缓存

javascript - 无法使用 Ajax 调用将数据发布到 Controller 的操作方法

php - readfile 下载空文件和错误的文件类型

html - 预标记宽度 :100% or max-width:100% overflow:auto is not flexible

html - Css 导航子菜单移动不起作用