Results 1 to 3 of 3

Thread: Combo used in grid with store loaded using filter value from existing grid row?

  1. #1

    Default Combo used in grid with store loaded using filter value from existing grid row?

    I have a grid that allows entry of job assignments for an event at a future date shown here

    For each row that is created, a job role must be selected from a combo that appears in the Job Title column (when clicked) to state what job the particular assignment is for. The assignments are automatically posted up on another form elsewhere on the website ("front end") where employees, can indicate their availability to work on them using a checkbox against each one. Their employee id and assignment id are captured and recorded.

    At some time nearer the date of the event, admin staff need to choose suitable employees for the assignments. This is to be done using combo boxes in the third column shown here .
    The server side php that provides the data when the store loads must be passed the event date and job role. It can then do a query against the database tables to get a list of employees who are available on that date, and who have that job role as their job title.

    I am having trouble figuring out how to accomplish this. Initially, I was thinking that I would need to use the beforeload event on the employeeComboStore to fill an employeeCombo when it was clicked as follows:
    PHP Code:
    // -------------------------------------------------------------------------------------
    // Add event_date as a baseParm for employeeComboStore, assigning the 
    // value obtained from the currently selected record in the 
    // bookingSelectorGrid sm
    // -------------------------------------------------------------------------------------
    <?php echo $ns?>.employeeComboStore.on('beforeload', function (employeeComboStore, options) {
        var bs_sm_record = <?php echo $ns?>.bookingSelectorGrid.getSelectionModel().getSelected();
           var as_sm_record = <?php echo $ns?>.assignmentGrid.getSelectionModel().getSelected();
           employeeComboStore.setBaseParam('event_date',bs_sm_record.data.event_date);
           employeeComboStore.setBaseParam('job_title',as_sm_record.data.job_title);
        });
    but this gives me an error "assignmentGrid.getSelectionModel().getSelected is not a function" when the grid loads, since at that point no row is selected.

    Can anyone suggest a good strategy for what I am trying to do?

    TIA.

  2. #2
    Sencha User conorarmstrong's Avatar
    Join Date
    Mar 2008
    Location
    Northern Ireland
    Posts
    224

    Default

    What about selecting that row in a beforeedit event listener on the editorgridpanel eg
    Code:
    listeners: {
    
    <snip>
    
    beforeedit: function(e) {
      e.grid.getSelectionModel().selectRow(e.row);
    }
    
    <snip>
    
    }
    ------------------------------------------
    Conor Armstrong
    tw: @evathedog
    web: rockstown.com

    Ext.ux.form.AutoCombo
    Ext.ux.SimpleIFrame
    Ext.ux.form.ToolFieldSet

    Knowledge is realising that the street is one-way, wisdom is looking both directions anyway.

  3. #3

    Default

    Thanks conorarmstrong, that was a good idea and I used it like this:
    Code:
    listeners: {
    	beforeedit: function(e) {
    		// For each cell that gets edited, check to see if it is the employee 
                    // field. If it is, load the employeeCombo passing it the 
                    // assignment ID 
    		if (e.field == 'id_employee') {
    			var id_assignment = e.record.data.id_assignment;
    			<?php echo $ns; ?>.employeeComboStore.load({
    				params: {
    					id_assignment: id_assignment
    				}
    			});
    		}
    	},
    Seems to work okay (so far).

Similar Threads

  1. Editor Grid: Store successfully loaded but not the grid
    By norizam61 in forum Ext 3.x: Help & Discussion
    Replies: 7
    Last Post: 13 May 2010, 1:32 AM
  2. [RESOLVED] Combo store loads when trigger pressed -even when store is loaded!
    By dlgoodchild in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 13 Aug 2009, 1:46 PM
  3. Replies: 2
    Last Post: 29 Jul 2009, 9:12 AM
  4. Ext.ux.grid.filter.ListFilter -> loaded store
    By tobiu in forum Ext 2.x: User Extensions and Plugins
    Replies: 2
    Last Post: 31 Mar 2009, 2:23 AM

Posting Permissions

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