Author Topic: Duplication data after applying/clearing filter  (Read 522 times)

pranit@srcomsec

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 99
    • View Profile
Duplication data after applying/clearing filter
« on: March 24, 2023, 02:30:03 pm »
We are getting duplication data issues with the grid. The steps, we followed as below.

1) Load data with grid - looks fine (refer to the screenshot - SRC_1.png)
2) Apply the range filter to the "N.Value" column (refer to the screenshot - SRC_2.png) - showing a duplicate "0.00" value
3) Select "0.00" & apply a filter to get the duplicate rows (refer to the screenshot - SRC_3.png)

Please advise the solution to fix the duplicate data issue.

My grid code is as below:
Code: [Select]
var loGroupModel =
{
on: false,
summaryInTitleRow: 'all',
showSummary: [false], //to display summary at end of every group.
grandSummary: true,
fixCols: false,
indent: 20,
collapsed: [true, true, true],
title: [
"{0} ({1})",
"{0} - {1}"
]               
};

var obj =
{
width: "auto",
flex: { one: true },
numberCell: { width: 60, show: false },
resizable: true,
filterModel: { on: true, header: false, type: 'local', menuIcon: true, hideRows: false },   //on: true,
menuIcon: true,
selectionModel: { type: 'row', mode: 'block', column: false },
blur: function (evt, ui) {
mGridUIFocus = ui; //global var
mPrevGridUIFocus = ui; //global var
},
editable: false,
stripeRows: false,
showTitle: false,
hwrap: false,
wrap: false,
strNoRows: 'No Net Position found.',
pageModel: { rPP: 50 },
columnTemplate: {
filter: {
crules: [{ condition: 'contain' }]
}
},
colModel: fsTableHeaders,
groupModel: loGroupModel,
rowInit: function (ui)
{
if (ui.rowData.pq_gtitle)
{
//console.log("pq_gtitle: " + ui.rowData);
return {
style: { "background": "#FAD5A5" }
};
}                
},
cellSave: function (evt, ui) {
this.refreshRow({ rowIndx: ui.rowIndx });
},

change: function () {
this.filter();
},
beforeCellClick: function (evt, ui)
{
if (this.SelectRow() != null && this.SelectRow().getSelection() != null) {
if (!evt.ctrlKey && this.SelectRow().isSelected(ui) && this.SelectRow().getSelection().length <= 1) {
return false;
}
}
}
};

var loData = "";
obj.dataModel =
{
method: "GET",
location: "remote",
beforeSend: function (jqXHR, settings) {
jqXHR.setRequestHeader("Content-Type", "application/json");
},

getUrl: function () {
return {
url: "URL to Get net postion data",
data: loData
};
},

getData: function (response) {
var loOrderJS = $.parseJSON(response.d);
data = loOrderJS;
return { data: data }
},
error: function (jqXHR, textStatus, errorThrown) {
customalerterror('Error!', jqXHR.responseText, '500px');
}
};

var grid = pq.grid("#gridfilter1", obj);
grid.one('lazyProgress', function () {
this.flex();
});


grid.on("scroll", function (evt, ui) {
mGridUIScrollX = this.scrollX();
mGridUIScrollY = this.scrollY();
mPrevGridUIScrollX = this.scrollX();
mPrevGridUIScrollY = this.scrollY();
});

grid.on("formatCell", function (row, column, value, data)
{
var groupLevel = this.iGroup.getGroupLevel(row);
if (groupLevel !== undefined && this.iGroup.isSummary(row)) {
var color;
switch (groupLevel) {
case 0:
color = "#FF0000";
break;
case 1:
color = "#FF0000";
break;
case 2:
color = "#FF0000";
break;
default:
color = "#FF0000";
break;
}
return {style: "background-color: " + color};
}
});

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Duplication data after applying/clearing filter
« Reply #1 on: March 24, 2023, 05:30:53 pm »
Please share a jsfiddle with reproducible issue so that it can be checked.

pranit@srcomsec

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 99
    • View Profile
Re: Duplication data after applying/clearing filter
« Reply #2 on: March 24, 2023, 08:52:28 pm »
Thank you for your quick response. It is tough to setup this up in jsfiddle.

Do you have any suggestions as per the code and screenshots shared with you?

One more question, I need to call my method after the user filter on the grid or clear filter.  Please advise.
« Last Edit: March 24, 2023, 09:01:31 pm by pranit@srcomsec »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Duplication data after applying/clearing filter
« Reply #3 on: March 27, 2023, 12:37:57 pm »
Quote
I need to call my method after the user filter on the grid or clear filter.  Please advise.

Please use filter event: https://paramquery.com/pro/api#event-filter

pranit@srcomsec

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 99
    • View Profile
Re: Duplication data after applying/clearing filter
« Reply #4 on: March 27, 2023, 02:43:05 pm »
Our grid is updating data every second. If we use the filter event code below then the grid refreshes every second after applying a filter. Please refer to the screenshot below & advise.

Code: [Select]
filter: function (event, ui)
{                   
      this.refreshDataAndView();
}

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Duplication data after applying/clearing filter
« Reply #5 on: March 27, 2023, 03:06:53 pm »
Filtering and updating data are different.

filter event fires only once when user filters the grid, so I'm not sure about your question.

pranit@srcomsec

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 99
    • View Profile
Re: Duplication data after applying/clearing filter
« Reply #6 on: March 29, 2023, 07:47:31 pm »
Thank you, as per the ticket below we have fixed our issue.
https://paramquery.com/forum/index.php?topic=4589.0