quinta-feira, 4 de abril de 2013

Remote Filtering using Delphi with ExtJS

POST #014
=======================================================================

Sometimes, you only need a specific subset of data from your dataset, but you need it filtered to a specific set of Records. After working with our filtered dataset, there will come a time when we want our original dataset back. When we filtered the dataset, the other Records didn't go away. They're still sitting in cache, to the side, waiting to be recalled. Rather than query the server again, we can simply clear our filter.

Client-side filtering is great, reducing our trips to the server. Sometimes, however, our record set is just too large to pull in at once. A great example of this is a paging grid. Many times we'll only be pulling in 10 Records at a time. The client-side filtering methods just are fine if we only want to filter the resident dataset, but most of the time we'll want a filter applied to all of our data.

Sorting data on remote calls is pretty easy, using Extjs, as we can set the property remoteSort to true (default value is false) and the proxy will pass the filter object as the parameter:

filter:[{"property":"subject","value":"mORMot"}].


So, basically if our Store was attached to a grid object, clicking on a column heading to sort the display would automatically pass the parameter value in its AJAX request, and our little server mORMot should be well enough to handle these request.

Filtering data on remote requests is a bit harder. We would pass parameters through the Store's load event, and act on those arguments in our mORMot server-side method. Our little mORMot should read the parameter filter (a json object) and perform the filtering on server side. The problem is: our mORMot uses another approach to filter data – it uses inlined parameters via SQLwhere and cannot read directly with parameter Filter coming from the client side.

This might look complicated, but it really isn't! Again, our mission here is to learn how mORMot handle with this task, it is important to have some understanding of what your server-side process is doing. The trick is: what we have to do here is just passing some expected parameters related to filtering using inlined aproach through HTTP request, mORMot will just ignore the option parameter filter.


Regards,

warleyalex from Sete Lagoas, Brazil


Tags: Remote Filtering with ExtJS; Remote ComboBox Filtering with Extjs; ExtJS with Delphi mORMot; remote Filter with Extjs and Delphi;


Nenhum comentário:

Postar um comentário