Announcement

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

    filterLocalData not working

    I am using SmartClient v110p_2016_09-08 (LGPL)

    I am trying to filter listgrid data locally :-

    Data Source
    ---------------
    isc.RestDataSource.create({
    ID:"StudentDataSource",
    dataFormat:"json",
    operationBindings:[
    {operationType:"add", dataURL:"api/Student", dataProtocol:"postMessage"},
    {operationType:"fetch", dataURL:"api/Student", dataProtocol:"getParams"},
    {operationType:"update",dataURL:"api/Student",dataProtocol:"postMessage",requestProperties:{httpMethod:"PUT"}}
    ],
    fields:[
    {name:"id", primaryKey:true},
    {name:"name"},
    {name:"age"}
    ]
    });

    List Grid
    ----------

    isc.ListGrid.create({
    ID:"StudentOldListGrid",
    dataSource:"StudentDataSource",
    autoDraw:false,
    width:"500",
    height:"500",
    autoFetchData:false,
    filterLocalData:true,
    showFilterEditor:true,
    filterOnKeypress:true,
    fields:[
    {name:"id"},
    {name:"name"},
    {name:"age", type:"int"}
    ]
    });

    As per document I am setting data using "setData" as below
    StudentDataSource.fetchData(null, "StudentOldListGrid.setData(data)");

    All data is loaded into grid correctly. When I try to filter data using filter editor, it again issues a server fetch passing criteria "/api/Student?name=R&_operationType=fetch". After this fetch code filters data locally until I clear all data. The question I have is that as I have already provided all the data using setData why smartclient is issuing additional fetch (when it has all data already). The problem I have with this is that I need to implement all filter logic at server side as well due to that fetch which I don't want to and because of which I am using filterLocalData at first place. P.S. I am seeing warning "*14:36:08.319:TMR1:WARN:Log:createDataModel method: data should be an array" before this fetch occurs.

    #2
    It looks like your setData() call either isn't actually occurring, or the "data" being passed in is something other than an Array, perhaps because your server code is not quite returning the right response to the RestDataSource.

    We can't run your code, so we can't tell which is the problem.

    Comment


      #3
      Response from server
      {
      "response": {
      "status": 0,
      "data": [
      {
      "klass": "student",
      "id": 1,
      "name": "Ratnesh Jain",
      "age": 30
      },
      {
      "klass": "student",
      "id": 2,
      "name": "Saurabh Chouhan",
      "age": 30
      }
      ]
      }
      }

      One update is that when I changed my code to set result set instead of data (like code below), additional fetch stopped occurring. Any reasons? But a fetch still occurs when I clear all fields from filter editor. Why when all the data is already fetched in first fetch?

      StudentDataSource.fetchData(null, function(response, data, request){
      isc.ResultSet.create({
      ID:"studentResult",
      dataSource:"StudentDataSource",
      allRows:data
      });
      StudentListGrid.setData(studentResult);
      });
      Last edited by SaurabhAripra; 9 Sep 2016, 14:52. Reason: Format changes only

      Comment


        #4
        When you set filterLocalData:true and then call setData(), per the docs, a ResultSet is automatically formed - in the same way that you now show doing manually in your fetchData() callback.

        It's not clear why this isn't happening, and again, we can't run your code since it's incomplete, and the most likely problem is code or settings you haven't shown.

        You could either:

        1. try modifying a sample to see if you can reproduce your issue, then show us that code

        or

        2. wrap up your code as a complete, minimal, ready-to-run test case that demonstrates the problem, and we can take a look

        Comment

        Working...
        X