Announcement

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

    updateCaches add operation not working?

    What am I doing wrong here, I click the test button which fires an updateCaches operationType: "add" but no record appears in the listgrid?

    Code:
       var ds = isc.DataSource.create({
            fields: [ { name: "ID", title: "ID" } ]
        });
    
        var grid = isc.ListGrid.create({
            dataSource: ds
        });
    
        isc.Button.create({
            title: "add",
            top: 200,
            click: function () {
                grid.dataSource.updateCaches({ operationType: 'add', data: {ID: "xxx"} });
            }
        });

    SmartClient Version: v8.2_2012-04-08/LGPL Development Only

    #2
    You did not declare a primaryKey.

    Comment


      #3
      Added primaryKey but its still not adding the record. No javascript error and no smartclient debugger error apparent.

      Current test case;

      Code:
          var ds = isc.DataSource.create({
              fields: [ { name:"ID", title:"ID", primaryKey:true } ]
          });
      
          var grid = isc.ListGrid.create({
              dataSource: ds
          });
      
          isc.Button.create({
              title: "test",
              top: 200,
              click: function () {
                  grid.dataSource.updateCaches({ operationType: "add", data: {ID: "xxx"} });
              }
          });

      Comment


        #4
        Another problem is that the DataSource has not fetched. Calling fetchData() will fix the problem, another route is to setData() with a ResultSet that has empty initialData (if you for some reason don't want to fetch).

        Comment


          #5
          Thanks. Using either the fetchData or setData methods make the updateCaches "add" work.

          For other readers in order to "...setData() with a ResultSet..." its not immediately obvious from the documentation that a ResultSet can be passed on a ListGrid.setData call. The ResultSet overview covers it though with "ResultSet can be passed to any component that expects a List"

          To use it;

          Code:
           var rs = isc.ResultSet.create({
                  dataSource: ds,
                  initialData: []
           });
          
           grid.setData(rs);

          Comment

          Working...
          X