Announcement

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

    SelectItem does not update its options after DataSource cache data change

    SmartClient Version (ISC_Core.js' header)
    Version v9.0p_2013-12-10 (2013-12-10)

    Browser
    Google Chrome 33.0.1750.154 m

    Problem
    We've got a SelectItem inside a DynamicForm, and its options are derived from a clientOnly DataSource. We set a new cache data in order to change its options, but the SelectItem is not redraw. We've tried invalidating the DataSource cache, marking the parent DynamicForm for redraw, and invalidating the SelectItem's display value cache, to no avail.

    Observations
    When the cache data is set right after the form creation (probably before the first redraw loop; see sample code), the SelectItem options are indeed updated.
    No error is logged to the console.

    Sample code
    Code:
    var dataSource = isc.DataSource.create({
      clientOnly: true,
      cacheData:  [
        {value: "old1", display: "Old item 1"},
        {value: "old2", display: "Old item 2"},
        {value: "old3", display: "Old item 3"}
      ]
    });
     
    var dynamicForm = isc.DynamicForm.create({
      width: 500,
      fields: [{
        name: "selectField",
        title: "Select item",
        type: "select",
        valueField: "value",
        displayField: "display",
        optionDataSource: dataSource
      }]
    });
     
    window.setTimeout(function() {
      dataSource.setCacheData([
        {value: "new1", display: "New item 1"},
        {value: "new2", display: "New item 2"},
      ]);
     
      /* None of these seem to have any effect: */
      dataSource.invalidateCache();
      dynamicForm.markForRedraw();
      dynamicForm.getField("selectField").invalidateDisplayValueCache();
     
      console.log("DataSource changed");
    }, 1000);  // When a shorter delay (e.g. 10ms) is set,
               // it works, even without any additional calls

    #2
    We figured it out. The required call is SelectItem.fetchData(). Thanks!

    Comment

    Working...
    X