No announcement yet.
  • Filter
  • Time
Clear All
new posts

    listGrid with pagination - asynchronously fill some data after every fetch

    Hi, I have listGrid with pagination. When the user scrolls down to get more data, after the data arrives, I need to call the server asynchronously to fill some missing data.
    I tried using the dataArrived method to do that, but it isn't good for me - because the listGrid already drawn the partial data, without updating fields' Value Maps.
    Do you have any ideas on how to do that?
    Last edited by kshamir; 26 Nov 2019, 02:33.

    Hi kshamir,

    why don't you do this directly on the server, before it sends data back to the client?
    This way you have a round trip less and no client code change at all.

    Best regards


      Blama, thank you for your input.
      This is a complex server-side infrastructure that will be difficult to change.
      All I want is to update the valueMap of some the fields that were retrieved on the current page (in a separate call to the server).
      Last edited by kshamir; 25 Nov 2019, 01:43.


        If you want a dynamic valueMap consider listGridField.optionDataSource.

        Other than that, you could use dataArrived to kick off a fetch that will update the valueMap, or use queuing to combine the initial fetch and the fetch of valueMap information.

        We’re not following what you mean about something being partially drawn.


          I will try to clarify.
          Let's assume that after fetching page #2 (by scrolling down the grid), I have this grid:
          Order Book name
          1 My book
          2 12345
          As you can see, 'Book name' in the second row shows the id instead of showing book's name.
          That's because the this field's valueMap wasn't updated with this new book. That's what I meant when I wrote 'Partial'.
          I don't want the grid to show this id, instead I want to fetch all the missing values and update each field's valueMap -> and only then the grid should show this new page data.

          When I try to fetch data for the valueMap in dataArrived method, it runs asynchronously -> which results unwanted behavior:
          First the 'id' is shown (like this example above), and only after x seconds the grid is redrawn and the 'Book name' displays the correct value (name instead of id).

          How can I make the grid 'wait' for all the data (including valueMap for all fields) to be resolved, before re-drawing itself to show new visible rows?

          Hope I managed to make myself clear


            Both of the methods we mentioned above would avoid any delay in how the data appears.

            There is no mechanism to prevent the entire grid from drawing if it has data, since that would basically be a hack, but as far as hacks go, you could:

            1. define a formatter for this specific field that returns blank if the valueMaps haven't been loaded


            2. put an opaque loading indicator over the whole grid until you finish your fetch of valueMaps


            3. create a dataProtocol:"clientCustom" DataSource that doesn't return the data from the original fetch until it has completed a second fetch for valueMap information (see docs of dataProtocol:"clientCustom" for details)