Announcement

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

    Setting Total Grid Rows client-side

    Is there any way on the client-side to set the Total Rows in a ListGrid? We are currently loading all of our initial data server-side and passing this data set directly to the ListGrid using ListGrid.data . Unfortunately, we cannot set the total rows on the grid, or in the response object, and pagination does not work.

    Is there any way to manually set the total number of rows on a ListGrid in the client side code? I know there is a getTotalRows() but I currently don't see a way to setTotalRows. If this isn't possible we would like to know if there is some way of forcing pagination without the ListGrid knowing what the true total row count is, i.e. when a user scrolls to the bottom of the rendered data set in the ListGrid.

    As a side note, once our initial data is loaded we use fetchData when a user clicks anywhere else on the tree to pull back the records and because we then have a ResultSet generated by fetchData(), the total number of rows is set and reflected in pagination and the scroll bar icon size.

    Also, because we aren't using fetchData for the initial load we don't have an entry in the RPC logs in the developer console so I was not able to use that method to troubleshoot this specific case.

    v9.1p_2014-08-24/Pro Deployment
    Chrome 37

    #2
    Take a look at ResultSet.initialData and initialLength - you can pass a ResultSet with your partial data to setData() and paging will continue from there.

    Comment


      #3
      As you have suggested I have created a ResultSet and set both initialData and initialLength successfully. The problem I now have is without setting allRows to 'true', it appears that the ResultSet attempts a fetch early on, even though I have passed in data to the initialData parameter. From the reference guide it appears that the initialData should take the place of any initial fetch. If I set allRows to 'true', I get the initial data set to display but then it appears that paging no longer works because the grid thinks it has all the data it needs.

      Is there any way to display the initial data without an initial server fetch, without setting allRows to true?

      To set the data on my ListGrid I have tried both the .setData() method on the ListGrid object and by setting the data parameter in the ListGrid object initialization. Both give me the same results as described above. I also tried manually setting fetchMode to "paged" with allRows set to false but it doesn't appear that this had any affect on the problem.

      Here is some of my sample code:

      Code:
      isc.MyGrid.create({
      	ID: "myGrid",
      	dataSource: myDataSource,
      	minFieldWidth: 80,
      	//data: mySet,
      	clipHeaderTitles: false
      });
      
      var mySet = isc.ResultSet.create({
      	initialLength: 1000,
      	//allRows: true,
      	fetchMode: "paged",
      	dataSource: myDataSource,
      	initialData: myInitialData
      });
      
      MyGrid.setData(mySet);

      Comment


        #4
        allRows is not a Boolean property but an Array of Records (see reference docs), so you should ignore any behaviors you observed after trying to set it.

        When you set initialData and initialLength, this will indeed avoid an initial fetch, so long as the data you provide fills the viewport and any draw ahead / fetch ahead (see ListGrid.drawAheadRatio and ResultSet.fetchSize). You can enable the "ResultSet" log category in the Developer Console to see why a fetch still results.

        We notice you're using a custom class "MyGrid" below - if in that subclass you were to call fetchData(), it would, as documented, overwrite your custom ResultSet with a newly created instance. Similarly, you subclass might set showAllRecords: true or other properties that would require all records to be loaded up front and this prevent paging from being used.

        Comment


          #5
          I have narrowed down the problem to the initialLength property. My initial data set has 75 records and my total row size is 278. If I pass the full set of initial data to my list grid a fetch is triggered.

          Code:
           surveyDetailsGrid.setData(mySet);
          I've set fetchSize and drawAheadRatio to values of 75 and this doesn't seem to have any affect. I also double checked my ListGrid to make sure I am not setting any parameters that would cancel out paging. If I pass in the result set to the list grid using the setData method with a range between 0 and 75, I get the data to display without a fetch but I don't have any paging on the table even though the initialLength is set to a value much larger.

          Code:
          surveyDetailsGrid.setData(mySet.getRange(0,75));
          The logs I am getting from the Developer Console are

          with range set: (data is rendered but no paging)
          Code:
          20:47:37.455:INFO:ResultSet:isc_ResultSet_0 (created by: undefined):creating auto-operation for operationType: fetch
          20:47:37.458:INFO:AdvancedCriteria:Criteria object:{} not explicitly marked as AdvancedCriteria - treating as SimpleCriteria.
          20:47:37.458:INFO:ResultSet:isc_ResultSet_0 (created by: undefined):setCriteria: filter criteria changed, invalidating cache
          20:47:37.458:INFO:ResultSet:isc_ResultSet_0 (created by: undefined):Invalidating cache
          20:47:37.459:DEBUG:ResultSet:isc_ResultSet_0 (created by: undefined):integrating 75 rows into cache at position 0
          20:47:37.459:DEBUG:ResultSet:isc_ResultSet_0 (created by: undefined):full length set to: 278
          
          20:47:37.468:DEBUG:ResultSet:isc_ResultSet_0 (created by: undefined):getRange(0, 75) satisfied from cache
          no range: (initial fetch is attempted that errors out)
          Code:
          20:48:55.437:INFO:ResultSet:isc_ResultSet_0 (created by: undefined):creating auto-operation for operationType: fetch
          20:48:55.439:INFO:AdvancedCriteria:Criteria object:{} not explicitly marked as AdvancedCriteria - treating as SimpleCriteria.
          20:48:55.439:INFO:ResultSet:isc_ResultSet_0 (created by: undefined):setCriteria: filter criteria changed, invalidating cache
          20:48:55.440:INFO:ResultSet:isc_ResultSet_0 (created by: undefined):Invalidating cache
          20:48:55.440:DEBUG:ResultSet:isc_ResultSet_0 (created by: undefined):integrating 75 rows into cache at position 0
          20:48:55.441:DEBUG:ResultSet:isc_ResultSet_0 (created by: undefined):full length set to: 278
          
          20:48:55.937:DEBUG:ResultSet:isc_ResultSet_0 (created by: undefined):getRange(0,29), cache check: 0,51 firstMissingRow: 0 lastMissingRow: 51
          20:48:55.937:DEBUG:ResultSet:isc_ResultSet_0 (created by: undefined):getRange: guessing forward scrolling
          20:48:55.938:INFO:ResultSet:isc_ResultSet_0 (created by: undefined):getRange(0, 29) will fetch from 0 to 75
          20:48:55.938:INFO:ResultSet:isc_ResultSet_0 (created by: undefined):fetching rows 0,75 from server
          20:48:55.938:INFO:ResultSet:isc_ResultSet_0 (created by: undefined):creating auto-operation for operationType: fetch
          
          20:48:56.391:DEBUG:ResultSet:isc_ResultSet_0 (created by: undefined):getRange(0, 14) satisfied from cache
          
          20:48:56.455:XRP1:INFO:ResultSet:isc_ResultSet_0 (created by: undefined):Received 0 records from server
          20:48:56.455:XRP1:DEBUG:ResultSet:isc_ResultSet_0 (created by: undefined):full length set to: 0
          20:48:56.455:XRP1:DEBUG:ResultSet:isc_ResultSet_0 (created by: undefined):integrating 0 rows into cache at position 0
          20:48:56.456:XRP1:INFO:ResultSet:isc_ResultSet_0 (created by: undefined):Fetch request returned range 0,0 differs from requested range 0,75. Assuming client/server batch size mismatch and clearing loading markers greater than 0
          20:48:56.456:XRP1:INFO:ResultSet:isc_ResultSet_0 (created by: undefined):cached 0 rows, from 0 to 0 (0 total rows, 0 cached)
          20:48:56.456:XRP1:INFO:ResultSet:isc_ResultSet_0 (created by: undefined):Cache for entire DataSource complete
          20:48:56.456:XRP1:INFO:ResultSet:isc_ResultSet_0 (created by: undefined):$391: sorting on properties [surveyStartTime,orgNodeDescription] : directions [false,true] : full cache allows local sort
          *I believe the last group of logs are from the failed fetch and can be ignored for this particular issue

          My ultimate goal is to send 75 records from the server in an initialData set and pass this data to the ListGrid from a ResultSet with the total rows value set at 278. Once the user scrolls through the initial data set of 75 records, pagination will kick in to retrieve the next 75.

          I would appreciate any feedback. Thank you for your time.
          Last edited by tcelikel; 10 Sep 2014, 08:48. Reason: formatting

          Comment


            #6
            Can you elaborate on "(data is rendered but no paging)"?

            If you've set initialLength, you should see a scrollbar that reflects that number of records. Grabbing the scrollbar and dragging into the unloaded area should then trigger a fetch to the server.

            If you aren't seeing this:

            1. please describe what you are actually seeing in detail

            2. make sure you test with just a normal ListGrid and not your customized class, to eliminate any possible problems there.

            Comment


              #7
              That solved the issue. You were correct in that my custom List Grid was the source of the extra fetch. I realized that having an initialSort in my ListGrid was causing an extra fetch, presumably because the dataset was too large to be sorted on the client.

              After removing the initialSort, I was able to get the data to display without the extra fetch. Paging now works as well with the normal way of setting the ResultSet data on the Grid
              Code:
               ListGrid.setData(myResultSet);
              Luckily the two columns I was initially sorting on are the first two in the grid so it looks like simply removing the initialSort fixes the issue. I'm not sure if there is a parameter to set that will force a client-side sort but it may come in handy down the road if we want to initialSort on some other columns. Thanks for all the guidance on fixing paging on an initial data load.

              Comment


                #8
                There's no reason to give up sort - just provide the initialData in the sort order you want, and provide sortSpecifiers to the ResultSet on creation.

                The ListGrid's display of the current sort order will reflect the sort specifiers on the ResultSet.

                From then on, changing the sort order will of course cause a fetch - it has to, as there's no valid way to sort a partial cache.

                Comment

                Working...
                X