Re-apply datatable filter not working

Hi,

I have two datatables, one controls the filtering of the other. So in the first table I have:

		$$('gasGrid').attachEvent("onafterSelect", function(id) {
			
			$$('forecastHeader').show();					
			$$('forecastGrid').show();

			// Get Currently Selected Row	
			var record = $$('gasGrid').getItem(id);
			$$('forecastGrid').filter('#SiteFK#', record.SiteID);

			$$('forecastHeader').define({template:record.SiteName});
			$$('forecastHeader').refresh();

		});

And this works fine, as you move through gasGrid the filtering is applied to forecastGrid.

However when I change a value in gasGrid I need to reload the data in forecast grid and re-applying the filter does not work. So I have this code:

		$$('gasGrid').attachEvent("onAfterEditStop", function(state, editor) {
			if (editor.column == 'GasForecastManual') {
				if (state.old != state.value) {
					$$('forecastGrid').clearAll();
					$$('forecastGrid').load($$('forecastGrid').config.url);
	
					var record = $$('gasGrid').getItem($$('gasGrid').getSelectedId());
					$$('forecastGrid').filter('#SiteFK#', record.SiteID);

				}
			}
		});

I have also tried doing $$(‘forecastGrid’).filterByAll(); but that doesn’t work either, the table contains all rows with no filtering applied.

Any ideas?

Thanks

Gary

To illustrate this I have put together a sample:

http://webix.com/snippet/655e24f6

If you edit the ‘gas’ value in the top grid this should re-load and filter the data in the bottom grid, but it doesn’t.

Thanks

Gary

Hi Gary,

filter() should be called after data are loaded. Please use callback parameter of load method. Here is the demo:

http://webix.com/snippet/5911c7c4

Thank you Maria!

Sorry just one more thing, on my local machine this works fine.

However when I deploy it what happens is the second grid hasn’t got the new data. Its perhaps because its an async call and the grid is rendering before the stored proc. has actually finished?

I don’t want to use a synchronous call as its not best practice, I guess I need to use a promise?

Thanks

Gary