Announcement

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

    Custom parameters in ListGrid filtering

    This thread recalls the second part of the following thread:
    http://forums.smartclient.com/showth...t=23364&page=2


    I have two ListGrids, Grid1 and Grid2.
    Grid1 shows some records and has a field named "ElementID".
    Grid2 shows informations about every Grid1's elements.
    At runtime, when i click on a Grid1's record, i get the ElementID and i create Grid2. Grid2 fetches data executing a jpa query (server side) depending on this ElementID, so i do the following:

    Grid1 code ---------------------------
    --------------------------------------
    .
    .
    Grid1.addCellClickHandler(new CellClickHandler() {

    @Override
    public void onCellClick(CellClickEvent event) {

    ListGridRecord record = hisInfoGrid.getSelectedRecord();
    int elementID = Integer.parseInt(record.getAttribute("elementID"));


    Grid2 = new Grid2(elementID));
    }
    });
    .
    .

    Grid2 code ---------------------------
    --------------------------------------
    public Grid2(int id) {
    .
    .
    String elementID = id;
    DSRequest myDSRequest = new DSRequest();
    Map params = new HashMap();
    params.put("elementID", elementID);
    myDSRequest.setParams(params);
    ListGrid.fetchData(new Callback(), myDSRequest);
    .
    .
    }


    Server side, i get the parameter, i execute the correct jpa query, and i return a DSResponse.

    Now, i need to do the same with filter and Grid header (for sorting), i need this parameter in DSRequests. This parameter must always be sent when fetching, but his value is decided at runtime.

    How can i set parameters at runtime for filtering operation?


    Thank you,


    Giervella
    Last edited by giervella; 13 Sep 2012, 07:26.

    #2
    You shouldn't send it as a parameter, you should send it as criteria, because that's what it is (inputs that cause only selected data to be returned). Sending it as a parameter is actually a hack.

    Criteria will be automatically preserved by the grid and sent along with subsequent sort and filter requests.

    Comment

    Working...
    X