Topic
  • 3 replies
  • Latest Post - ‏2012-11-15T20:23:11Z by kevintap
Prakash_uit
Prakash_uit
18 Posts

Pinned topic Custom Data Retriever for Data Column modifier - Sorting not working

‏2012-01-05T09:36:49Z |
Hi All,
I have a scenario where in implemented the CustomDataRetriever for the data column modifier data to be populated, as we have some 2000-5000 records of data we are forced to go for customdataretriever.

My problem now here is when i enable the sorting in the data column modifier, the link is coming on the header, but when i click on the link/header the data remains in same order, its not sorting as expected.

If anyone have faced this issue earlier/ have some solutions/ideas for this issue, please help me out in this regard. Thanks in advance.....
Updated on 2012-11-15T20:23:11Z at 2012-11-15T20:23:11Z by kevintap
  • kevintap
    kevintap
    747 Posts

    Re: Custom Data Retriever for Data Column modifier - Sorting not working

    ‏2012-01-05T15:42:12Z  
    When you extended the CustomDataRetriever base class, did you override the default implementation of the sort method (from the SortableData interface)?

    public boolean sort(String sortBy, String sortType, boolean ascending);

    This sort method is called to allow the paged data retriever to attempt to sort the data in an efficient manner. The default implementation of sort simply returns false, which means that sorting is not supported. In order to properly support sorting, this method must re-fetch data from the back end system in a sorted manner and return true.

    As an example, if this data retriever was obtaining data from a SQL database the implementation of this sort method would need to do something like this:
    1) append "ORDER BY sortBy" to the base SQL query
    2) re-execute the SQL query
    3) fetch the first batch of results from the result set
    4) return true from the sort method
  • saikiran
    saikiran
    20 Posts

    Re: Custom Data Retriever for Data Column modifier - Sorting not working

    ‏2012-11-15T11:54:07Z  
    • kevintap
    • ‏2012-01-05T15:42:12Z
    When you extended the CustomDataRetriever base class, did you override the default implementation of the sort method (from the SortableData interface)?

    public boolean sort(String sortBy, String sortType, boolean ascending);

    This sort method is called to allow the paged data retriever to attempt to sort the data in an efficient manner. The default implementation of sort simply returns false, which means that sorting is not supported. In order to properly support sorting, this method must re-fetch data from the back end system in a sorted manner and return true.

    As an example, if this data retriever was obtaining data from a SQL database the implementation of this sort method would need to do something like this:
    1) append "ORDER BY sortBy" to the base SQL query
    2) re-execute the SQL query
    3) fetch the first batch of results from the result set
    4) return true from the sort method
    Hi All

    I tried the approach. In the sort method if I return the flag true, then It internally calling the getResultData with argument value 0.

    So in sort method I am storing the sort method argument into the object members and returning true. And in getResultData I am calling the services to get the sorted result.

    In the page it is always going to page1. Is this correct way of doing it?

    Is there any way to stay in the current page after sort?
  • kevintap
    kevintap
    747 Posts

    Re: Custom Data Retriever for Data Column modifier - Sorting not working

    ‏2012-11-15T20:23:11Z  
    • saikiran
    • ‏2012-11-15T11:54:07Z
    Hi All

    I tried the approach. In the sort method if I return the flag true, then It internally calling the getResultData with argument value 0.

    So in sort method I am storing the sort method argument into the object members and returning true. And in getResultData I am calling the services to get the sorted result.

    In the page it is always going to page1. Is this correct way of doing it?

    Is there any way to stay in the current page after sort?
    The behavior that you describe sounds correct. Following a request to sort the data, it should return to view the first page of the results. This is typical behavior for web applications as after you sort the data, your previous position/page number is meaningless.
    The postings on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.