jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Filtering returns "No data to display"
This topic contains 4 replies, has 2 voices, and was last updated by chakrameste 10 years ago.
-
Author
-
Hi there,
I’m new to JqWidgets, and the projects i’ve been working on needed filtering, wich i have implemented with no problem.
However, i need to create a new grid, and i used the working ones that i have, as a template for the new one. The grid is working with no problems, but the ‘filter’ function isn’t. It always returns “No data to display”.After a while debugging i have noticed that in the ‘getfilterinformation’ method, it returns 4 filters instead of one. I mean, the filter is being applied to four columns, instead of only the one wich is suposed to filter.
Here is my code for the creation of the grid:
CreateGrid = function () { var cellsrendererImage = function (row, columnfield, value, defaulthtml, columnproperties) { var imageStatusVerde = '@Url.Content("~/content/images/statusSLA.png")'; var imageStatusVermelha = '@Url.Content("~/content/images/statusSLAVermelha.png")'; var imageStatusAmarela = '@Url.Content("~/content/images/statusSLAAmarela.png")'; if (value == "0") { return '<center><img src=' + imageStatusVerde + ' /></>'; } else if (value == "1") { return '<center><img src=' + imageStatusVermelha + ' /></>'; } else if (value == "2") { return '<center><img src=' + imageStatusAmarela + ' /></>'; } } //cellsrendererImage var cellsrendererToEuros = function (row, column, value) { return "<center>" + CustomJs.ToThousandsComaSeparatorString(value.replace(',', '.')) + ' €</>'; } //cellsrendererToEuros var cellsrendererToDate = function (row, column, value) { if (selectedViewMode == "ViewPerDay") { return "<center>" + value.substring(0, 11) + '</>'; } else { return "<center>" + value + '</>'; } } //cellsrendererToDate $("#JqxGrid").jqxGrid( { width: 1250, height: 710, autoheight: true, altstart: 1, theme: 'custom', altrows: true, showemptyrow: true, statusbarheight: 27, filterable: true, columnsheight: 24, autoshowloadelement: false, editable: true, showstatusbar: true, showaggregates: true, selectionmode: 'singlecell', sortable: true, columns: [ { editable: false, text: 'Day', filtertype: 'number', datafield: 'Day', renderer: columnrenderer, cellsrenderer: cellsrendererToDate, aggregatesrenderer: function (aggregates, column, element) { return "<div class='jqxGridStatusBar jqxGridStatusBarSLA' id='jqxtotalDay'>...</div>"; } }, { editable: false, text: 'Scanner', width: '190', filtertype: 'number', datafield: 'Scanner', renderer: columnrenderer, cellsrenderer: cellsrendererNumbers, aggregatesrenderer: function (aggregates, column, element) { return "<div class='jqxGridStatusBar jqxGridStatusBarSLA' id='jqxtotalScanner'>...</div>"; } }, { editable: false, text: 'Type', width: '190', filtertype: 'checkedlist', datafield: 'Type', renderer: columnrenderer, cellsrenderer: cellsrendererNumbers, aggregatesrenderer: function (aggregates, column, element) { return "<div class='jqxGridStatusBar jqxGridStatusBarSLA' id='jqxtotalType'>...</div>"; } }, { editable: false, text: 'Read Rate', width: '190', filtertype: 'number', datafield: 'ReadRate', renderer: columnrenderer, cellsrenderer: cellsrendererNumbers, aggregatesrenderer: function (aggregates, column, element) { return "<div class='jqxGridStatusBar jqxGridStatusBarSLA' id='jqxtotalReadRate'>...</div>"; } }, { editable: false, text: 'SLA (€)', width: '190', datafield: 'SLA', filtertype: 'number', renderer: columnrenderer, cellsrenderer: cellsrendererToEuros, aggregatesrenderer: function (aggregates, column, element) { return "<div class='jqxGridStatusBar jqxGridStatusBarSLA' id='jqxtotalSLA'>...</div>"; } }, { editable: false, text: 'Status', filterable: false, width: '50', datafield: 'Status', renderer: columnrenderer, cellsrenderer: cellsrendererImage, aggregatesrenderer: function (aggregates, column, element) { return "<div class='jqxGridStatusBar jqxGridStatusBarSLA'>...</div>"; } }, { text: '', exportable: false, filterable: false, datafield: 'Edit', width: '60', aggregatesrenderer: function (aggregates, column, element) { return "<div class='jqxGridStatusBar jqxGridStatusBarSLA'>...</div>"; }, editable: false, columntype: "image", cellsrenderer: function (row) { var dataRecord = $("#JqxGrid").jqxGrid('getrowdata', row); var imgId = "coment_" + row; if (dataRecord.Comments == 1) { var imageComment = '@Url.Content("~/content/images/editComments.png")'; } else { var imageComment = '@Url.Content("~/content/images/addComments.png")'; } return "<center><a href='#' onclick='popupShow(" + '"' + dataRecord.DAY + '",' + '"' + dataRecord.GROUPVALUE + '",' + row + ")' ><img src=" + imageComment + ' id= "' + imgId + '" /></a></>'; } } ] }); $("#JqxGrid").bind("bindingcomplete", function (event) { if (firstTerminalGridLoadDone == false) { $('#jqxDateTimeTo').jqxDateTimeInput('setDate', new Date(filterDateTo)); $('#jqxDateTimeFrom').jqxDateTimeInput('setDate', new Date(filterDateFrom)); firstTerminalGridLoadDone = true; } window.setTimeout(CalculateGridTotal, 200); }); $("#JqxGrid").bind("filter", function (event) { console.log(event); var filterinfo = $("#JqxGrid").jqxGrid('getfilterinformation'); console.log(filterinfo); if (filterinfo.length == 0 && filterFromDateTime) CustomJs.ShowPageLoadingDiv(); }); }
What am i doing wrong here? Can somebody help me?
Hi chakrameste,
console.log(filterinfo) will not give you how many filters are applied. I would suggest you to read the Grid’s API documentation page about the “getfilterinformation” method. The Grid’s filtering has no issues regarding how many filters are applied or not.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comLet me explain myself better. When I “console.log(event.args.filters)” in my working examples, what I get is this object:
[Object { filter={…}, datafield=”V1″}]
This is ok because i was searching in a column that uses “V1″ datafield.
When i do the same on the non-working examples I get:
[Object { filter={…}, datafield=”AdmissibleBags”}, Object { filter={…}, datafield=”TotalFractions”}, Object { filter={…}, datafield=”SLA”}]
And i am only searching in one column, because i am using the default filtering funcionality.
I have been reading the documentation but have not been able to find an answer to my problem. Have rebuilt the page from scratch and i keep having the same problem. Do you have any idea what can be causing this?
After more debugging I saw that this error only happens when the column has “filtertype” set to “number”. If I remove “filtertype” from every column, the filtering starts working just fine. However, since some columns work with numbers, i really need to filter by number, because of the filtering conditions.
Once again, can someone help me out here? Do you know why “filtertype: number” is making this error? Or can you provide me with a piece of code for a custom filter that behaves exactly like “number” works?
Got it. It was a problem with the data i was getting with the ajax request. I was treating all data like string. Stupid of me. Thanks a lot and keep up the good work.
-
AuthorPosts
You must be logged in to reply to this topic.