Announcement

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

    ComboBox item filtering

    SmartClient : Smartclient v8.2p_2012-06-07 - Power Edition

    Browser : IE 9

    Hi we have this requirement where we are doing a client side filter data in a combo box and if the results are not found it should have the ability to add the new entry to the list and also persist to DB using an RPC call. For this we need to display a + symbol next to the combo box when the filtered results are 0 and persist the new entry to the DB when the + symbol is clicked.

    The data to the combo box is loaded on server startup and filtering is done on the client side.

    This are few properties for the combo box.

    name:"xxxxx",
    title: "Company",
    editorType:"comboBox",
    optionDataSource: "yyyy",
    fetchMissingValues : true,
    completeOnTab: true, addUnknownValues: true,
    filterLocally: true,
    changeOnKeyPress: true,

    change: function(form, item, value, oldValue){
    console.log('Change : '+item.pickList.getData().size());},

    changed: function(form, item, value){
    console.log('Changed : '+item.pickList.getData().size());}

    My intention is to capture the filtered results size and if it is 0 display the + symbol and add the new entry. But in both the functions above I get the size of the previously filtered results.

    If I have a total size of 500
    if I type the first character I see the size as 500 though the filtered results size is only 400.
    When I type the 2nd charecter then I see 400.

    Can you please suggest If I need to override a different function or call a different method on pick list to get the exact count of the filtered results.

    #2
    Assuming you are using a DataSource here, when the DataArrived handler first fires, the ResultSet that the PickList is using is made available. You can call getLength() on this ResultSet to determine the number of visible rows.

    Comment


      #3
      Thank you for the prompt reply.

      Overriding the dataArrived function and checking the data size helped me enable and disable the + button. This is what I have done.

      dataArrived: function(startRow,endRow,data){
      if(data.size() == 0) this.form.getItem('addNewItem').enable();
      else this.form.getItem('addNewItem').disable();
      }

      Comment

      Working...
      X