1. #1
    Sencha User murrah's Avatar
    Join Date
    Oct 2007
    Location
    Katoomba, Blue Mountains, west of Sydney, Australia
    Posts
    381
    Vote Rating
    11
    murrah will become famous soon enough

      0  

    Default Ext.ux.store.sqlStorePlugin - trimQuery SQL on local stores (experimental)

    Ext.ux.store.sqlStorePlugin - trimQuery SQL on local stores (experimental)


    Hi,

    I thought it might be useful to be able to query/filter an Ext store in memory using SQL. So, I have created a wrapper/store plugin for the trimQuery JS SQL engine to explore the idea. It works quite well (so far) with the following caveats: 1. its no good for AIR since the trimQuery library uses eval() (although I havent actually tested it myself); 2. the time part of the datetime field is causing problems (which may well be my fault!)

    I have set up a live demo - 3 examples - starting here http://www.murrah.com.au/JSLib/extjs...id-query1.html.

    The first two examples are just to get the basics introduced. They allow you to use the new store.filterBySQL() method. Example 3 goes further to show how you can create a grid based on a store that is dynamically created by doing sql joins on one or more Ext.data.store objects (array stores in this case). I guess you could use the dynamic store for other components (eg combo box). Again, not tested.

    You can dynamically place the grid columns and hide/show them so that the columns reflect the fields returned by the sql.

    I havent fully tested it and may not proceed any further unless I can find another JS SQL library like trimQuery that will run on AIR. If it is of use to someone else maybe they can develop the idea further. Also, there doesnt seem to be a whole lot of activity on the development side of trimQuery.

    Having said that, it does raise some interesting possibilities for filtering and dynamic grids. I learned a lot by doing it. I am thinking that it could be the basis of a user defined reporting system. eg build an SQL generator (if one doesnt already exist) in Ext on top of the joined stores and save the generated SQL. Filter the dynamic store and use the PrinterFriendly type components to generate reports from the resulting grid. Maybe there are other applications too.

    If you want to experiment, note that the trimQuery syntax is very specific with regards to case sensitivity. See the syntax page here: http://code.google.com/p/trimpath/wiki/TrimQuerySyntax

    Cheers,
    Murray

    Download (with Firefox, not IE) and unzip. Place the enclosed folder in your extjs/examples folder. It should then work out of the box.
    Attached Files