1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    71
    Vote Rating
    2
    DavidSSL is on a distinguished road

      0  

    Default Enable and disable cell upon changes in another cell

    Enable and disable cell upon changes in another cell


    In my grid panel, I have a column which contains a combobox and it is being used as an autocomplete box. Now, if a value is selected from the combobox, I want to make some of the cells in the other columns editable for that particular row. So the question is how do I do that?

    I've read from other posts about ColumnModel and isCellEditable but in the api documentation http://docs.sencha.com/ext-js/4-0/ for ext.js 4.0, I can't find them or any related example. Can you please point me in the correct direction?

  2. #2
    Sencha User
    Join Date
    Jun 2011
    Posts
    71
    Vote Rating
    2
    DavidSSL is on a distinguished road

      0  

    Default


    I don't normally bump threads but I still can't find the answer to the original question. I've read this http://www.sencha.com/forum/showthread.php?141932-How-to-enable-or-disable-a-cell-editor-dynamically-based-on-some-other-cell-value&p=636210#post636210

    b
    ut the various methods mentioned are not available in version 4.0.2b.

    So, I'm at a loss. Please help.

  3. #3
    Sencha User
    Join Date
    Feb 2011
    Posts
    63
    Vote Rating
    0
    joelchu is on a distinguished road

      0  

    Default


    I have done more or less what you want to do (start date - need to be fill out before the end date activate)

    The idea is (not very simple).

    Catch the select events in the grid

    (not sure why they call that - but its actually when a cell being highlight , click or enter into - "select" got fire) the first version I done was based on cellclick. Then I found out if I tab into a cell nothing happen. But the "select" event cover for both.

    PHP Code:
    .... code etc etc set up the grid ...

    listeners: {
         
    select: function(viewrecordrowIndex colIndex listeners) {
                
    // now this bit is very import 
                
    var header view.getHeaderCt().getHeaderAtIndex(colIndex);
                var 
    field  header.dataIndex
                
    // you use the field to travel up to get the column name 
                // now you get the next bit also very import 
               
    var editor header.getEditor();
     
               
    /* now do whatever you want. Thank you very much. That will cost you £2000  ... that just for the coffee I drank to figure this out .... ;) */


         
    }


  4. #4
    Sencha User
    Join Date
    Jun 2011
    Posts
    71
    Vote Rating
    2
    DavidSSL is on a distinguished road

      0  

    Default


    Thanks very much. I'll try that out and let you know if that works. As regards the £2000, I doubt I'd be able to find that chunk of change but if you're ever in Tallinn, I'd be happy to buy you a cup of coffee .

  5. #5
    Sencha User
    Join Date
    Feb 2011
    Posts
    63
    Vote Rating
    0
    joelchu is on a distinguished road

      0  

    Default


    well, I did count how much coffee I drank to get a feature done ... that's how I bill my client

    anyway, the beauty (lot of people say otherwise because the old methods are all gone ...) of this is - its generic. Disregard whatever editor type you have (I have combo, textfield, number field , date field etc etc on the same grid) once you get the editor - do the stuff you need with the editor as you would as the individual type of editors.

    The other tip is - if you want to find the other value - look into the record and you will get everything.

  6. #6
    Sencha User
    Join Date
    Jun 2011
    Posts
    71
    Vote Rating
    2
    DavidSSL is on a distinguished road

      0  

    Default


    Hey Joel,

    I'm not sure how getting the editor object helps me. If we take your example as an illustration of what I want to achieve. As I understand it, you have a grid with "Start date" and "End Date" columns.

    Initially the "End Date" column is not editable. It's only after the "Start Date" is entered that the "End Date" for that row will become editable and not the whole column i.e. only for that "End Date" cell.

    Can you please shed some more light?

    TIA,

    David

  7. #7
    Sencha User
    Join Date
    Jun 2011
    Posts
    71
    Vote Rating
    2
    DavidSSL is on a distinguished road

      0  

    Default


    Hi,

    I think I know what you meant. I'll give it a go and if I can't get the solution I'll ask you again.

    David

  8. #8
    Sencha User
    Join Date
    Feb 2011
    Posts
    63
    Vote Rating
    0
    joelchu is on a distinguished road

      0  

    Default


    A. You have to stop thinking the way you have been - stop thinking in a linear way. This is very important when you try to deal with javascript - especially the Ext way. Understand how those object fit together.

    B. Stop thinking to make "something" something else. How about make it editable / non-editable? I.E. disable on init - enable when condition meet?

    C. Think 4 ways at the same time. The X , Y , Z of the grid (Z being the target cell) then plus an Alpha which is the condition.

    won't have time to show you the full size working example - that part alone is 1500 lines long ...

  9. #9
    Sencha User
    Join Date
    Jun 2011
    Posts
    71
    Vote Rating
    2
    DavidSSL is on a distinguished road

      0  

    Default


    Thanks Joel for the advice. I now understand that Ext.Js 4 require a shift in thinking. It's quite interesting but at the moment I fail to see the advantages of the Ext.Js way of doing things, in this particular instance but with more experience, I might do.

    Thank you once again.

    David

  10. #10
    Sencha User
    Join Date
    Feb 2011
    Posts
    63
    Vote Rating
    0
    joelchu is on a distinguished road

      0  

    Default


    Experience don't come with time. They come with - doing stuff.

    I already give you a head start. This is about 90% more than I have when I started out to try to figure out how to get this done.

    ---------- TIPS ------------

    Why I said you have to change the way you think - especially you are thinking linear - I need A to do B.

    How about B ask A something then B decided what to do?

    P.S. mine grid has 6 date fields 10 combobox and 20 text field 15 number fields - each one of them determine something happen on the other fields (with a group expand on the right hand side which is not know during the run time) so this is why you have to think in isolation first. A would not do stuff for B. Therefore C is dead - how about the other way around. C wants to do something then ask B - then B ask A.

    -----------------------------

    I personally hate to teach people especially holding hands, perhaps because I grow up in the 70s

Thread Participants: 1

Tags for this Thread