Announcement

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

    ListGrid not showing all records

    Hi,

    We are using SmartGWT Pro 3.0 version.
    I am creating one ListGrid and setting the datasource, in DB we have around 8000 rows and while fetching data using datasource I am properly setting the total no of rows available in DB in my DSResponse object but while running this it is showing only first 75 rows. Any idea what I am missing, below is the code example

    <DataSource titleField="bank_alerts.bank_alert_id" tableName="bank_alerts" dataURL="http://localhost:8080/mconsole/chart/dataRequestHandler" ID="bank_alerts">
    <fields>
    <field type="integer" title="Incident" name="bank_alerts.bank_alert_id" length="1"/>
    <field type="text" title="Rule Number" name="bank_alerts.bank_alert_profile_id" length="1"/>
    <field type="text" title="Card Number" name="bank_alerts.is_login_card_id" length="1"/>
    <field type="datetime" title="Incident Time" name="bank_alerts.create_time" length="1"/>
    <field type="text" title="Delivery Channel" name="bank_alerts.action" length="1"/>
    </fields>
    </DataSource>

    Client Code:-
    ListGrid bankAlertsGrid = new ListGrid();
    bankAlertsGrid.setEmptyMessage("No Alerts Available");
    DataSource dataSource = DataSource.get(Constants.VIEW_BANK_ALERTS);
    bankAlertsGrid.setDataSource(dataSource);
    bankAlertsGrid.setCanAutoFitFields(false);
    bankAlertsGrid.setShowAllRecords(true);
    bankAlertsGrid.setAutoFetchData(true);
    bankAlertsGrid.setDrawAheadRatio(2);


    Server Code:-
    dsResponse.setData(matchingItems);
    dsResponse.setStartRow(startRowIndex);
    dsResponse.setEndRow(endRowIndex);
    dsResponse.setTotalRows(totalRows);

    #2
    Whatever values you're attempting to set in server-side code, they appear to be not correct. Look at the RPC Tab in the Developer Console to see the values actually delivered to the browser and troubleshoot from there.

    Comment


      #3
      I checked the Developer Console and RPC DSResponse, its properly setting all the value

      [
      {
      data:[
      some data
      ],
      endRow:50,
      invalidateCache:false,
      isDSResponse:true,
      queueStatus:0,
      startRow:0,
      status:0,
      totalRows:33280
      }
      ]

      Any idea what could be the reason?

      Comment


        #4
        Well, you said 8000 records and your are returning totalRows of ~33000. But other than that, no, the problem does not appear to be in the code you've shown, and all of our automated tests in this area are passing. You will need to isolate the issue further.

        Comment


          #5
          when I use bankAlertsGrid.fetchData() it works properly but when I use
          bankAlertsGrid.fetchData(new Criteria(), new DSCallback()
          {
          @Override
          public void execute(DSResponse response, Object rawData, DSRequest request)
          {
          bankAlertsGrid.setData(response.getData());
          }
          });

          its not working as per expectation.
          Any idea what I am missing here?

          Comment


            #6
            There is no need to call 'setData()' on the grid in the fetch callback.
            The "listGrid.fetchData()" API automatically populates the listGrid with the data returned by the server - the callback is there to allow you to do additional processing (knowing that the asynchronous fetch operation as completed).

            Moreover as written this code will indeed break things as you've described.
            A normal listGrid.fetchData call handles populating the list grid with data as follows -- it creates a ResultSet instance and assigns it to the ListGrid's "data" attribute. This then handles having a partial range of rows cached and incrementally fetching pages of data as the user scrolls.
            The dataSource request that actually gets sent to the server when you first issue a grid.fetchData() request is for the first visible page of data (75 rows) which (if you let it run normally) the ResultSet will fold into its cache and allow the ListGrid to display.

            What your code is doing is taking this first page of data (a raw array of records available via response.getData()) and applying it to the ListGrid via a 'setData()' call.
            This essentially throws away the ResultSet, so you end up with a list populated with a simple array of records rather than the data object designed to handle incremental fetching and data paging, etc.

            Regards
            Isomorphic Software

            Comment


              #7
              I wanted to fetch based on some Criteria which cannot be done using listGrid.fetchData() that is the reason I am using listGrid.fetchData(criteria, callBack) and in the callBack I am doing some business logic (which I didn't mentioned in my code example)

              Comment


                #8
                What you describe should be absolutely fine. In your callback you should just avoid calling "listGrid.setData(...)" - the grid is already populated with the data from the fetch at this point.

                If, with that line removed, things still aren't behaving as expected, we'll need to see a test case demonstrating the problems you're experiencing to comment further

                Thanks
                Isomorphic Software

                Comment

                Working...
                X