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

    Working...
    X