Amit Shrestha

Posts Tagged ‘extjs

[Migrating to http://xtrace.blogspot.com , so follow there for further updates]

click here to see solution : http://xtrace.blogspot.com/2011/09/extjs-tree-filter-filtering-tree-items.html

Solution contains a ready to run demo as well

You can see solution here: http://xtrace.blogspot.com/2011/09/rearrangine-extjs-windows-in-cascade-as.html  [sorry for that, i am migrating blog over there]

http://xtrace.blogspot.com/2011/09/stateful-example-in-extjs-saving-tree.html  [Migrating to this blog,,flollow there for further updates]

More on extjs at: http://xtrace.blogspot.com/search/label/extjs

First read this:  http://dev.sencha.com/deploy/ext-4.0.2a/docs/#/api/Ext.state.Stateful-cfg-stateful

Following example demonstrate simple way to save a selected item in tree:

  1. this.tree = Ext.create(‘Ext.tree.Panel’, {
  2.     viewConfig: {
  3.         plugins: {
  4.             ptype: ‘treeviewdragdrop’,
  5.             appendOnly: true
  6.         }
  7.     },
  8.     height: 350,
  9.     width: 400,
  10.     stateEvents: [‘saveSelectedItem’],
  11.     stateId:’myTreeId’,
  12.     stateful:true,
  13.     rootVisible: false,
  14.     mySelectedItem:”,//my own added Variable
  15.     getState : function () {
  16.         /*this is place where we state what things are to be saved*/
  17.         console.log(‘saving’+this.mySelectedItem);
  18.         /*we return thing to be save in format key:value*/
  19.         return {
  20.             mySelectedItem: this.mySelectedItem
  21.         }
  22.     },
  23.     applyState : function (state) {
  24.         /*this is place where we recover the saved state*/
  25.         console.log(state);
  26.         console.log(“Previosuly selected “+state.mySelectedItem);
  27.      },
  28.     listeners:{
  29.        itemclick:{fn:function (view, record, item, index, even) {
  30.             console.log(“saving item:”+record.data.text);
  31.             this.mySelectedItem =  record.data.text;
  32.             this.fireEvent(‘saveSelectedItem’);
  33.        }}
  34.     }
  35. });
…………