Announcement

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

    FilterBuilder and dynamic DataSource

    Hello,

    I'm using DynamicDSGenerator for creating a changeable datasource. When I load the changed datasource the columns of ListGrid are change fine according to the new fields.
    But the FilterBuilder doesn't change. It contains still the old fields.
    (Maybe the reason is that the ID of the datasource is not changed.)

    I use this: DataSource.load("dynamicDS", callback, true);
    The callback function is:

    final Function callback = new Function() {
    @Override
    public void execute() {
    DataSource dynamicDS = DataSource.getDataSource("dynamicDS");
    dsResultList.setDataSource(dynamicDS);
    filterBuilder.setDataSource(dynamicDS);
    }
    };

    I made a workaround. I create a dummy datasource with one field, and the FilterBuilder's datasource is set to this dummy DS before and it works.

    (...)
    filterBuilder.setDataSource(dummyDS);
    filterBuilder.setDataSource(dynamicDS);
    (...)

    Is there any more elegant solution?
    Thank you for your answer in advance.

    #2
    Best practice is to use a new ID for a new DataSource. The behavior of DataBoundComponents when a DataSource is changed on the fly is undefined; it is legal for them to cache details about the DataSource for performance reasons.

    Comment


      #3
      It was a good idea! I generate the DataSource name on the client side:

      dsName = DS_NAME_PREFIX + dsIDnumber++;
      DataSource.load(dsName , callback, true);

      I check the DS_NAME_PREFIX on the server side:

      public DataSource getDataSource(String id, DSRequest dsRequest) {
      if (id.startsWith(DS_NAME_PREFIX))
      {...
      sw.write("<DataSource ID=\"" + id + "\"");
      ....}

      It works fine! The FilterBuilder also refreshes. Thank you!

      BTW: What happen with the unused DataSources? Are staying in the server cache? They are not neccessary anymore. How to unregister or remove them?
      Thank you.

      Comment


        #4
        If you're done with them, your should use destroy() on the client-side to get rid of them.

        Comment


          #5
          It works! Thank you for your support.

          Comment

          Working...
          X