0
votes

Extending Ext.form.field.Picker I am creating a custom component. Its very similar to a DatePicker but instead of a calendar, I expand a tree with checkboxes. When a node is checked, I have to manually set the value of the textfield with the text of the node. My question is, how can I add/delete nodes to the textfield? For adding I am doing something like

var picker = Ext.create("Ext.tree.Panel", {
      store: this.store,
      floating: true,
      hidden: true,
      autoScroll:true,
      useArrows:true,
      animate:false,
      animCollapse:false,
      shadow: false,
      manageHeight: false,
      listeners: {
          scope:this,
          itemclick: function(view, record, node, rowIndex, e){
            record.set("checked", true);
            this.setValue(this.getValue()+","+record.data.text); //add tree selection to textfield
          }
      },

but is there a better way to add tree selections to the textfield?

And more importantly, how will I delete a value, say value2

textfield: value1, value2, value3

1
check out this sencha example in the kitchensink. Specifically, the onCheckedNodesClick section.weeksdev

1 Answers

0
votes

Better would be to always get the array of checked nodes with tree.getChecked() method, loop through the resulting array to pluck texts from the records and finally set the complete value regardless what the text field already contained.

That eliminates any need of "deleting" value2.