Results 1 to 5 of 5

Thread: listener for cell selection for extjs grid with some constraint

  1. #1

    Default Answered: listener for cell selection for extjs grid with some constraint

    I have a grid which contains just one column. Each row essentially contains just a name. When I click on a particular name I populate a form on the right side of the column using that selected name.

    Now what I wish to do is whenever a user selects ANOTHER name, whatever changes he has made in the components on the form on the right side for the last selected name, I wish to save them. All I need is a method to be able to just launch this saving function whenever he moves on to the next name.

    The tricky thing is that the save should be done BEFORE I populate the components on the right side for this new selection. For populating I am using a `selectionchange` listener.

    So in essence I want to be able to know my previous selection name and to be able to launch a save function and then populate the form with the current selection name. I need something like 'beforeclick listener' which allows me to do something before the click functionality is executed via selectionchange listener

    Here's a flow for clarity:

    Code:
     
        let user select one name -> 
        let user make changes on the form on right side -> 
        let user select new name -> 
    
        // I need help in the next step
    
        launch save function for previously selected name -> 
        populate the right hand side form using new/current selection.

  2. The sequence of triggered events on change selection is:
    1. beforeselect
    2. beforedeselect
    3. deselect
    4. select
    5. selectionchange
    There are many ways to obtain this behavior, a good one cold be to save changes and clean form on deselect and populate form on select.

  3. #2

    Join Date
    Dec 2013
    Location
    Italy
    Posts
    88
    Answers
    9

    Default

    The sequence of triggered events on change selection is:
    1. beforeselect
    2. beforedeselect
    3. deselect
    4. select
    5. selectionchange
    There are many ways to obtain this behavior, a good one cold be to save changes and clean form on deselect and populate form on select.

  4. #3

    Default

    Thanks a lot for the help. This approach would most certainly work. Can you please guide me through the docs page for deselect. I couldn't find any examples on the net for this deselect listener.

  5. #4

    Default

    Also, is it so that after the user selects another name the previous one's deselect listener is invoked? The problem is that I have written the following code but I don't know how to extract the name of the previously selected name.

    Code:
    listeners : {
        'deselect' : function(sm, selectedRecords) {
             console.log("1. " + selectedRecords);
             var value = selectedRecords[0].get("name"); // in selectionchange listener this works and gives me the name (in string) selected but here selectedRecords[0] is undefined.
    },

  6. #5

    Join Date
    Dec 2013
    Location
    Italy
    Posts
    88
    Answers
    9

    Default

    You find everything in the ExtJS documentation: http://docs.sencha.com/extjs/4.2.0/#...Ext.grid.Panel

    Select and deselect listeners are fired for each single row/record, so the listeners should look like:
    Code:
    listeners: {
        deselect: function(grid, record) {
            var name = record.get('name');
            // save new name
        },
        select: function(grid, record) {
            var name = record.get('name');
            // load name to form
        }
    }

Similar Threads

  1. HOW TO add cell listener to grid row?
    By juanbill in forum Ext 5: Q&A
    Replies: 3
    Last Post: 11 Feb 2015, 6:50 AM
  2. Cannot bind to grid selection with cell selection model
    By nikolay.bobrovskiy in forum Ext 5: Bugs
    Replies: 5
    Last Post: 22 Sep 2014, 10:46 AM
  3. Replies: 4
    Last Post: 11 Sep 2013, 5:48 AM
  4. Replies: 1
    Last Post: 1 May 2012, 8:16 AM
  5. how i set window constraint true in extjs 4?
    By asifshaikh in forum Ext: Q&A
    Replies: 2
    Last Post: 6 Apr 2012, 6:43 AM

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
  •