1. #1
    Sencha User
    Join Date
    Jul 2010
    Posts
    34
    Vote Rating
    0
    techakone is on a distinguished road

      0  

    Default Reloading a Combobox using onTriggerClick

    Reloading a Combobox using onTriggerClick


    Hi all,
    In one of my applications i am using a grid with a CheckboxSelectionModel, and above the grid, i have a combobox that contains "Actions" that can be applied to the selected rows in the grid(values from the selected rows are used as parameters to reload the combobox's store). I know there are better ways to do this but this is how the client wants it. As a proof of concept i wrote the following code. This works overall except that on the initial click, even though the right data is returned in the store, the list of new values is not displayed. Clicking to collapse the box, and then clicking to open it again then loads the store fine and display the values. Any subsequent click works fine. I need your help in figuring out why the initial click does not display the list of values. That is where i am puzzled:

    Code:
    //Store Definition
        var toActionStore = new Ext.data.JsonStore({
            fields: ['actionDesc','actionVal'],
            storeId: "actionStore",
            url: "json/taskActions.wjson?" ,
            root: "actions",
            listeners:
            {
                load:function(store)
                {
                    com.util.display.hideLoading();
                },
                exception:function(proxy, type, action, options, response, args)
                {
            
                }
            }
        });    
        //Combobox definition
        {
            id: 'WorkActions',
            hideLabel: false,
            xtype:'combo',
            displayField: 'actionDesc',
            valueField: 'actionVal',
            lazyRender:false,
            lazyInit:false,
            mode: 'local',
            triggerAction: 'all',
            listEmptyText: 'Select an Action',
            editable: false,
            width: 100,
            store: toActionStore,
        }
        //OnTriggerClick overrride
        var actionComboBox = Ext.getCmp('WorkActions');
        actionComboBox.onTriggerClick = function()
        {
            if(!this.isExpanded())
            {
                var taskGrid = Ext.getCmp('WorkData');
                var selectedTasks = taskGrid.getSelectionModel().getSelections();
                console.log("TriggerACtion: "  + this.triggerAction + " allQuery: " + this.allQuery);
                
                if (!Ext.isEmpty(selectedTasks)) 
                {
                    var record = selectedTasks[0];
                    var opId = record.get("operationId");
                    var asgId = record.get("taskId");
                    
                        com.util.display.showLoading('Loading Task Actions...');
                         this.store.reload(
                        {
                            params:
                            {
                                userId:userId,
                                userRole:userRole,
                                operationId:opId,
                                taskId:asgId
                            },
                            callback:function()
                            {
                                var actionComboBox = Ext.getCmp('WorkActions');
                                actionComboBox.onFocus({});
                                actionComboBox.expand(); 
                                actionComboBox.el.focus();
                                
                            }
                        }        
                        )
                    
                }
            }
            else
            {
                
                this.collapse(); 
            }
        }
    Thanks in advance for your insight.
    Last edited by techakone; 17 Dec 2010 at 10:59 PM. Reason: Additional Code

  2. #2
    Sencha User
    Join Date
    Jul 2010
    Posts
    34
    Vote Rating
    0
    techakone is on a distinguished road

      0  

    Default


    Just FYI for those with the same issue. I solved mine, i dug around a bit on the forum and came up with this here solution. I added the code to reload the store in the beforequery event listener of the combobox:

    Code:
        //Combobox definition
        {
            id: 'WorkActions',
            hideLabel: false,
            xtype:'combo',
            displayField: 'actionDesc',
            valueField: 'actionVal',
            lazyRender:false,
            lazyInit:false,
            mode: 'local',
            triggerAction: 'all',
            listEmptyText: 'Select an Action',
            editable: false,
            width: 100,
            store: toActionStore,
            listeners:
            {
                beforequery:function(qe)
                {
                    //console.dir(qe);
                    
                    var assignmentGrid = Ext.getCmp('taskGrid');
                    var selectedTasks = assignmentGrid.getSelectionModel().getSelections();
                    if (!Ext.isEmpty(selectedTasks)) 
                    {
                        qe.cancel=true;
                        var record = selectedTasks[0];
                        var opId = record.get("opId");
                        var asgId = record.get("taskId");
                        var actionStore = Ext.StoreMgr.get('actionStore');
                        var actionComboBox = Ext.getCmp('WorkActions');
                        this.store.removeAll();
                         this.store.reload(
                        {
                            params:
                            {
                                userId:userId,
                                userRole:userRole,
                                operationId:opId,
                                assignmentId:asgId
                            },
                            callback:function()
                            {
                                
                            }
                        }        
                        )
                        //this.expand(); 
                    }
                    else
                    {
                          this.store.removeAll();
                          
                    }
                    return qe;
                }
            }
        }
    Doing so helped me fix my problem. The store is reloaded and the correct values are displayed. I tried moving that code previous to the expand event listener but that was incorrect as the combobox was already expanded and it was causing issues with the dom.

    Hope this helps somebody.

Similar Threads

  1. error on firing onTriggerClick() in combobox
    By ShashankaN in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 22 Sep 2010, 2:21 AM
  2. Reloading combobox
    By janixams in forum Ext 1.x: Help & Discussion
    Replies: 2
    Last Post: 23 Jun 2008, 7:45 PM
  3. [Solved]Overriding onTriggerClick for ComboBox?
    By kjordan in forum Ext 2.x: Help & Discussion
    Replies: 14
    Last Post: 7 Jan 2008, 11:18 AM
  4. [1.0.1a] ComboBox possible bug in onTriggerClick
    By theo in forum Ext 1.x: Bugs
    Replies: 1
    Last Post: 16 May 2007, 5:13 PM

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar