I'm using SmartClient_v121p_2020-04-14_PowerEdition. I have a ListGrid backed by a client only DataSource. As I receive new data, I update the DataSource. I have a requirement to filter this data by "Last X Seconds", so I created a FilterBuilder to be able to do this. The problem that I am having is that when I select the options in the FilterBuilder to filter by, let's say the last 10 seconds, it initially filters the data that already exists in the grid, but any new data being added does not get filtered. If I change the number of seconds in the FilterBuilder and re-apply the filter, it starts working. I tried to reproduce this in the Feature Explorer with the code below, but I cannot. However, I can consistently reproduce this in my project. I was wondering if there was perhaps a known bug in the version that I am using and/or if there is a workaround.
Thanks in advance!
Code:
var formatString = "MM/dd/yyyy HH:mm:ss"; isc.DateUtil.setInputFormat("MDY"); isc.DateUtil.setNormalDatetimeDisplayFormat(formatString); isc.DateUtil.setShortDatetimeDisplayFormat(formatString); isc.DateUtil.setNormalDisplayFormat(formatString); isc.DateUtil.setShortDisplayFormat(formatString); var ds = isc.DataSource.create({ ID: "myDS", fields: [ {name: "display_time", type: "datetime", canFilter: false}, {name: "time", type: "datetime", timeUnitOptions: ["hour", "minute", "second"]}, {name: "id", type: "text"} ], dataFormat: "json", clientOnly: true }); isc.FilterBuilder.create({ ID:"advancedFilter", dataSource:"myDS" }); isc.ListGrid.create({ ID: "myList", width:700, height:224, alternateRecordStyles:true, dataSource: "myDS", autoFetchData: true, fields:[ {name:"display_time", align: "center", formatCellValue: function(value) { var validDateTime = isc.DateUtil.parseInput(value); if( validDateTime !== null ) { return isc.Time.toTime(validDateTime, "to24HourTime", true); } return value; }}, {name:"time", width: 200, align: "center", hidden: true}, {name:"id", align: "center"} ]}); isc.IButton.create({ ID:"filterButton", title:"Filter", click : function () { myList.filterData(advancedFilter.getCriteria()); } }) isc.IButton.create({ ID:"clearFilterButton", title:"Clear", click : function () { myList.clearCriteria(); } }) isc.VStack.create({ membersMargin:10, members:[ advancedFilter, filterButton, clearFilterButton, myList ] }) function sleep(milliseconds) { return new Promise(resolve => setTimeout(resolve, milliseconds)); } async function sendData() { for( var i = 0; i < 30; i++ ) { var dt = new Date(); dt.setMilliseconds(0); var msg = {display_time: dt, time: dt, id: i}; ds.addData(msg); await sleep(3000); } } sendData();
Comment