jquery datagrid ajax,jquery - Filtering datagrid with ajax request - Stack Overflow

作者分享了在使用DataGrid Fuel UX进行数据过滤时遇到的问题,即初次加载后切换筛选项再点击显示按钮,数据网格会重复加载相同数据。文章探讨了可能的原因,涉及DataSourceGrid对象的初始化和数据更新机制。
摘要由CSDN通过智能技术生成

I just used datagrid FuelUX with a couple of select for filtering but, i got the follow problem:

When i perform then click event btnShow's i initialized the properties DataSourceGrid's and i send a filter for ajax request, the first time works fine, but when i change the selected item from the select and i push btnShow button the datagrid reload data but with the same information that the previous filter and no matter how many times i change the selected item from select control, in datagrid i got the same information.

Regards

$("#btnShow").on("click", function () {

var dataSourceGrid = new DataSourceGrid({

filter: { ID: JSON.stringify(parseInt($("#cboSelect").val())) }, //Here i'm trying to filter to datagrid

url: "StudentList.aspx/GetStudent", columns: [{

property: 'IDStudent',

label: 'ID',

sortable: true,

cssClass: "text-center"

}, {

property: 'Name',

label: 'Name',

sortable: true

}],

formatter: {}

});

var grid = $('#grdItems');

grid.datagrid({

dataSource: dataSourceGrid

});

grid.datagrid('reload');

});

var DataSourceGrid = function (options) {

this._url = options.url;

this._columns = options.columns;

if (options.formatter != undefined) {

this._formatter = options.formatter;

}

if (options.filter != undefined) {

this._filter = options.filter;

}

};

DataSourceGrid.prototype = {

columns: function () {

return this._columns;

},

data: function (options, callback) {

var self = this;

var ajaxParam;

_optionsGrid = options;

_callbackGrid = callback;

_formatterGrid = self._formatter;

ajaxParam = {

type: "GET",

url: self._url,

data: self._filter, //this parameter never change after the first time

method: CallbackGrid // this is my callback function to format datagrid(search, pagination, etc)

}

ajaxRequest(ajaxParam); //Here is my ajax request

}

};

UPDATE: I've been checking the loader.js file and i think the problem might be in $.fn.datagrid. The option param have the datasource property and inside that, the filter property, the first time data is undefined and perform data = new Datagrid(this, options) and load the filter that i sent, but the next time, data change to not undefined and it never perform data = new Datagrid(this, options) again and never change the filter value. I don't know how to solve this because this code is high level javascript for me :p.

I hope this help, regards.

$.fn.datagrid = function (option) {

return this.each(function () {

var $this = $(this);

var data = $this.data('datagrid');

var options = typeof option === 'object' && option;

if (!data) {

$this.data('datagrid', (data = new Datagrid(this, options))); //only the first time load the filter value

}

if (typeof option === 'string') data[option]();

});

};

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值