locked
How to prevent auto refresh on HTML client table? RRS feed

  • Question

  • Hi friends,

    Just learning Lightswitch and am having a problem that I can't seem to fix. I have an HTML query screen that has many user selectable parameters that are used to filter the contents of a table that has thousands of rows. I need to display some aggregate information on the query results, so have had to turn paging off.

    This is obviously very slow - it takes several minutes for the screen and its data to load, and several minutes every time a query parameter is changed.  

    It seems like the best way to fix this would be to somehow disable auto refresh on the results table so that the user could load the screen, select the query parameters they wanted, and then click a "run query" button to display the results.

    I've tried setting the results table to isVisible = false, and isEnabled = false until the run query button is clicked, but that has no effect, the table still refreshes every time a parameter is changed.

    Any thoughts? Thanks so much,

    Stephen

     

    Friday, October 2, 2015 5:55 PM

Answers

  • I figured out another way to do it that was pretty quick & easy.

    I added a query parameter on a field that would always have data - the ID field. On the form's created property I set the value of the ID param to = empty, thus not return any records and causing the form to load quickly.

    After the users selects their parameters, they click the [Run Query] button which sets the ID param to null so that all records are returned. The query runs and is now much faster returning only the queried data..

    Stephen


    • Marked as answer by sbarash Friday, October 2, 2015 9:41 PM
    Friday, October 2, 2015 9:41 PM

All replies

  • Essentially what you want to do is to prevent the query from executing each time a query parameter is changed, so that the query is only refreshed at the end once the user has selected all the query parameters. You should be able to achieve this by introducing another set of screen variables that you display to the user (not directly linked to the query parameter variables) and then have a [Refresh] button that sets the values of all those variables to the actual query parameter variables in a single go. That way the user can select all the values they want and then click the refresh button for a single refresh of the query.

    Regards, Xander. My Blog

    Friday, October 2, 2015 7:58 PM
  • Thanks Xander. Working on it now, but this is going to take a bit of work.

    Isn't there something I could do with databind? Set in to null for the results table or something until the [Refresh] button is pushed?

    Seems like there's got to be another way...

    Stephen

    Friday, October 2, 2015 8:38 PM
  • There is nothing with data binding that I can think of that will solve this. Ideally there should be a way to disable auto refresh on the query so that you can explicitly refresh the query when required, but that is not the case out of the box. So the work around above is the only one I know of for now. One would have to look into the msls file to find out how to disable/enable auto refresh but it will not be trivial.

    Regards, Xander. My Blog

    Friday, October 2, 2015 8:59 PM
  • Xander's idea is the way since, as he point out, there is no AutoExecuteQuery in HTML Client.

    You should be able to eliminate the button click with dataBind, however.

    1) add new screen prop for each required query param

    2) add those to layout for user input

    3) write a function setParams() to check all required props have values. if yes then assign values to query params.

    4) contentItem.dataBind("value",function(){setParams();}); in post render of each required prop.

    Note:  Query paraqms must be required.

    HTH,

    Josh

    Friday, October 2, 2015 9:19 PM
  • I figured out another way to do it that was pretty quick & easy.

    I added a query parameter on a field that would always have data - the ID field. On the form's created property I set the value of the ID param to = empty, thus not return any records and causing the form to load quickly.

    After the users selects their parameters, they click the [Run Query] button which sets the ID param to null so that all records are returned. The query runs and is now much faster returning only the queried data..

    Stephen


    • Marked as answer by sbarash Friday, October 2, 2015 9:41 PM
    Friday, October 2, 2015 9:41 PM