Results 1 to 4 of 4

Thread: unable to set default value from xtype: 'combo' selection at new grid window

  1. #1
    Sencha User
    Join Date
    Aug 2014
    Posts
    3
    Vote Rating
    0
      0  

    Default Answered: unable to set default value from xtype: 'combo' selection at new grid window

    Hello Experts,
    We have a requirement to display plant name based on dynamically plant selected in a grid view. I tried all the options so far but unable to succeed.

    My requirement is for any new entries to be inserted into a screen, a new window will open up and in that window, i have plant, plant name, storage location as input fields. Based on the plant selection by the user at first column, plant name and storage location should populate. i am able to create the dynamic selection of plant name and storage location into respective combo boxes, so user can select from there. since one plant will have multiple storage locations, so the combo box is working as desired by user, as they have to again select one storage location from the drop down.

    Issue: However one plant will have only one plant name, and currently in drop down the respective plant name is appearing. I want to make that as default selection instead of user again selecting from the drop down.

    I tried the value option, and listeners etc etc. But it is not helping.
    even hard coding with id is also not helping out.

    please suggest if any alternative solution to this issue.

    Code snippet is as given below.

    var editorName = {
    xtype : 'combo',
    id : 'plantName',
    allowBlank : true,
    forceSelection: false,
    store: PlantNameStore,
    displayField: 'plantRender',
    valueField: 'plantName',
    <%-- value : PlantNameStore.getAt(0).get('plantName'),--%>
    queryMode: 'local',
    typeAhead: true,
    minChars: 1,
    flex : 1,
    triggerAction: 'all',
    width : 200,
    selectOnTab: true,
    selectOnFocus: true,
    emptyText: "Select Plant Name"
    <%-- listeners: { load: function(store) {
    var record = {};
    record[me.valueField] = '';
    record[me.displayField] = '0100';
    store.insert(0, record);
    }
    }--%>
    <%-- listeners: {
    load: function () {
    //this sets the default value to plantName after the store loads
    var combo = Ext.getCmp('comboName');
    combo.setValue(this.first().data.id);
    }
    }--%>
    <%-- listeners: {
    afterrender: function(combo) {
    var recordSelected = combo.getStore().getAt(0);
    combo.setValue(recordSelected.get('plantName'));
    alert (recordSelected);
    }
    }--%>
    <%-- listeners: {
    boxready: function(){
    this.setValue(this.getStore().getAt(0).get(this.plantName),true);
    // fire the select event ( Event in extjs )
    this.fireEvent('select',this);
    }
    }--%>
    };

    var PlantNameStore = Ext.create('Ext.data.Store', {
    fields : ['plantId', 'plantName', 'plantRender'],
    autoLoad: true,
    proxy: {
    type: 'ajax',
    reader: {
    type: 'json'
    },
    api: {
    read : 'Test.htm?action=read'
    }
    }
    });

    PlantNameStore.load();

    since it is a single filed value, instead of string population, can i select from data base, directly the value via a page attribute and display in screen.

  2. Hi,

    You can set a load listener on the combo's store to set the value of the combo using the single store's record. Below is an example:


  3. #2
    Sencha User slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,165
    Answers
    505
    Vote Rating
    255
      0  

    Default

    Hi,

    You can set a load listener on the combo's store to set the value of the combo using the single store's record. Below is an example:


  4. #3
    Sencha User
    Join Date
    Aug 2014
    Posts
    3
    Vote Rating
    0
      0  

    Default

    though the default selection is now occurring as per below suggested code, however the render To functionality is actually displaying the combo in the main panel now. I mean i have a main panel and then a new window in which the grid display is occurring. when i wrote below code in my grid editor, the combo is shifted to main panel instead of appearing in new window grid box.

    Please suggest.

  5. #4
    Sencha User
    Join Date
    Aug 2014
    Posts
    3
    Vote Rating
    0
      0  

    Default closed: got the solution for default selection in combo

    Hi,
    I could find the soluton by adding a listener to my store load as below.
    listeners: {
    select: function(combo, record, eOpts) {
    PlantNameStore.load({
    params: {
    plant: combo.getValue()
    }
    })
    storageStore.load({
    params: {
    plant: combo.getValue()
    }
    })
    var recordSeleted = combo.findRecord(combo.valueField, combo.value);
    var selectedName = recordSeleted.data.plantName;
    var gridSelect = Ext.getCmp('PGridNew');
    var position = gridSelect.getSelectionModel().getCurrentPosition();
    var cellToUpdate = gridSelect.getSelectionModel().getCurrentPosition();
    var recordAtPosition = gridSelect.getStore().getAt(position.row);
    recordAtPosition.set("plantName",selectedName);

    thank you for the valuable suggestions.

    regards
    Mamata

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •