Announcement

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

    How to 'manually' trigger the loading spinner within the listgrid

    Hello,
    I'm going to enhance my grid widget to make the customized Search Bar can have 'exactly the same' loading spinner with the filter embedded in the ListGrid as below while it is loading.
    How can I do to make Case 1 has the same loading spinner in Case 2?

    Here is how I did to make the search bar work with the ListGrid (set with AutoFetchData)

    Case 1: Filter from Search Bar (The Loading Message would NOT be displayed)
    Step 1: update the search Bar value
    Step 2: trigger ListGrid.refreshData()
    => DataSource.transformRequest(DSRequest dsRequest) would be triggered automatically
    => Use the search Bar value & dsRequest.getCriteria() to compose a SearchCriteria for REST service
    => after received the REST response, execute
    DataSource.updateTable(DSRequest dsRequest, List<T> tableList, int totalRows) {
    int rowSize = tableList.size();
    ListGridRecord[] data = setRecords(tableList);

    DSResponse dsResponse = new DSResponse();
    dsResponse.setStartRow(dsRequest.getStartRow());
    dsResponse.setEndRow(dsRequest.getStartRow() + rowSize);
    dsResponse.setTotalRows(totalRows);
    dsResponse.setData(data);
    dsResponse.setStatus(DSResponse.STATUS_SUCCESS);
    processResponse(dsRequest.getRequestId(), dsResponse);
    }
    Click image for larger version  Name:	Picture1.png Views:	1 Size:	284.7 KB ID:	258180

    Case 2: Filter from the filter editor in the ListGrid (The Loading Message would be displayed automatically)
    Step 1: ListGrid would would trigger DataSource.transformRequest(DSRequest dsRequest) would be triggered automatically
    => Use the search Bar value & dsRequest.getCriteria() to compose a SearchCriteria for REST service
    => after received the REST response,execute
    DataSource.updateTable(DSRequest dsRequest, List<T> tableList, int totalRows) {
    int rowSize = tableList.size();
    ListGridRecord[] data = setRecords(tableList);

    DSResponse dsResponse = new DSResponse();
    dsResponse.setStartRow(dsRequest.getStartRow());
    dsResponse.setEndRow(dsRequest.getStartRow() + rowSize);
    dsResponse.setTotalRows(totalRows);
    dsResponse.setData(data);
    dsResponse.setStatus(DSResponse.STATUS_SUCCESS);
    processResponse(dsRequest.getRequestId(), dsResponse);
    }
    Click image for larger version  Name:	Picture2.png Views:	1 Size:	344.1 KB ID:	258181

    I tried to use DSRequest.setShowPrompt(true), but it doesn't work.
    I'm wondering, does the loading spinner would only be triggered when the Criteria in the DSRequest is different?
    or is there anyway, I can manually trigger the spinner?

    #2
    The spinner appears if the grid makes a request to the server to get new data.

    It will not appear for a call to refreshData() because that API is specifically designed to do a background refresh where the grid never goes blank - that is the entire (well documented) point of that API!

    We're not sure why you tried to implement a search bar with refreshData() but the normal approach would be to call fetchData() with new criteria. You can get the criteria currently in the filter editor (so that those aren't dropped) by calling getFilterEditorCriteria() and then combining the returned criteria with whatever you are injecting from your search bar.

    Comment


      #3
      Hello Isomorphic,
      Thank you for previous response. It solved my previous scenario.

      Now, I'm wondering can I trigger the spinner when scrolling the listgrid for different usedcase.
      Currently, the listgrid is set autoFetchData, and the grid would send a request with different StartRow and EndRow when scrolling.
      However, the loading spinner would not be popped up when scrolling.
      It only pop up when the filter is change or when I forcibly invoke invalidCache.

      Is there anyway I can do to make the spinner pop up when scrolling and keep the cache in the same time?

      Comment


        #4
        We don’t do this, by design, because a spinner would occlude rows that were already loaded. We would recommend that you do not implement this approach either. It would be complicated and awkward to do so.

        You could consider the different variations of rpcRequest.showPrompt if you want some kind of hint to the user that a fetch is going on.

        Comment

        Working...
        X