1. #1
    Sencha User
    Join Date
    Feb 2011
    Location
    Gurgaon, Haryana, India
    Posts
    7
    Vote Rating
    0
    jnabhishek is on a distinguished road

      0  

    Default how to dynmicall load store in Editor grid

    how to dynmicall load store in Editor grid


    1) We are populating a combo box, which is getting response from the server - how we can make any value selected (default selection) when it is rendered ?
    So as, when we do
    Code:
    Ext.getCmp('cmb_access_level').value
    it shall return us the selected value.

    2) We have a page which has a Combo box and Editor grid. Depending on the combo box value selection (on change of selected value) from the drop down, we have to populate the grid data (by making a AJAX call to the server).
    How we can modify/update/refresh the Store for EditorGird with the new data received from server (on the basis on combo box value selection) at runtime ?

    Initial Data Store defination for Combo box:
    Code:
    Ext.namespace('Ext.access');
    Ext.access.accesslevel = new Ext.data.Store({
     url: '../data/accesslevel.xml',
     autoLoad: true,
     reader: new Ext.data.XmlReader( {
       record: 'AccessLevel'
         }, [
             'Level',
             'Description'
         ]
     )
    });
    Ext.reg('accesslevellist', Ext.access.accesslevel);
    Code for Combo box
    Code:
    {
     xtype: 'combo',
     colspan: 1,
     width: 100,
     boxMaxWidth: 100,
     store: Ext.access.accesslevel,
     displayField: 'Description',
     valueField: 'Level',
     mode:'local',
     queryMode: 'local',
     name: 'cmb_access_level',
     id: 'cmb_access_level',
     typeAhead: true,
     listeners: {
      'change': this.getAccessLevelInfo
     }
        },
     
        .
        .
    Initial Data Store defination for Grid:
    Code:
    Ext.namespace('Ext.accesslevel');
    Ext.accesslevel.details = new Ext.data.Store({
     url: '../data/accesslevelinfo.xml',
     autoLoad: true,
     reader: new Ext.data.XmlReader({
      record: 'Table'
            }, [ 
             { name: 'TableName', mapping:'@TableName', type:'string'}, 
      { name: 'Create', type: 'bool' },
      { name: 'Read', type: 'bool'},
      { name: 'Update', type: 'bool'},
      { name: 'Delete', type: 'bool'}
        ] 
     )
    });
    Ext.reg('accessleveldeatils', Ext.accesslevel.details);
    Code for Editor Grid
    Code:
    {
     xtype: 'editorgrid',
     colspan: 5,
     width: 636,
     height: 200,
     store : Ext.accesslevel.details,
     stripeColumns: true,
     stripeRows: true,
     columnLines: true,
     name:'grd_accesslevel.details',
     id:'grd_accesslevel.details',
     columns: [
         {
      dataIndex: 'TableName',
      header: bundle.getMsg('lbl_accessadministration_page_table'),
      sortable: true,
      width: 100,
      align: 'center',
      editor: {
          xtype: 'textfield'
      }
         },
         {
      dataIndex: 'Create',
      header: bundle.getMsg('lbl_accessadministration_page_create'),
      sortable: true,
      width: 100,
      align: 'center',
      editor: {
       xtype: 'checkbox'
      }
         },
         {
      dataIndex: 'Read',
      header: bundle.getMsg('lbl_accessadministration_page_read'),
      sortable: true,
      width: 100,
      align: 'center',
      editor: {
       xtype: 'checkbox'
      }
         },
         {
      dataIndex: 'Update',
      header: bundle.getMsg('lbl_accessadministration_page_update'),
      sortable: true,
      width: 100,
      align: 'center',
      editor: {
          xtype: 'checkbox'
      }
         },
         {
      dataIndex: 'Delete',
      header: bundle.getMsg('lbl_accessadministration_page_delete'),
      sortable: true,
      width: 100,
      align: 'center',
      editor: {
       xtype: 'checkbox'
      }
         }
     ]

  2. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,605
    Vote Rating
    326
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    1) We are populating a combo box, which is getting response from the server - how we can make any value selected (default selection) when it is rendered ?
    Isn't this just setting a value config option, or calling setValue()? Note that the value needs to be that of your configured valueField.

    Code:
    Ext.getCmp('cmb_access_level').value
    Use getValue(), don't access the field directly.

    2) ...
    How we can modify/update/refresh the Store for EditorGird with the new data received from server (on the basis on combo box value selection) at runtime ?
    The easiest way is to use the store's load() method. See the API docs for more. Alternatively, if you already have the data loaded from a separate request you could just pass it into the store using loadData().

Thread Participants: 1