Editor cell shapeShifter

  1. #1

    Editor cell shapeShifter

    Hi,

    I am trying to do something weird.

    I have a gridpanel that contains something like this :

    Property Value Unit
    ------------- ---------- --------
    IP 12.23.35.156 IP
    Brand Tipco Brand
    Nb 3 Int

    I want to edit the IP value. I want my field to be a textField with an IP regex validation.
    I want to edit the Brand value. I want my field to be a combobox with a list of Brands.
    I want to edit the number value. I want my field to be a TextField with an int maskRe.

    With the following code, I get :
    I edit the IP value first, my field is an "IP field" but then when I edit the brand field, the event is fired but the trigger does not appear.
    When I edit the Brand value first, my field is an "Brand field" and the store loaded but then when I edit the IP value, the tigger does not disappear.

    How is it possible make things right ?

    Here is the code :

    In the value column :

    <Editor>
        <ext:ComboBox ID="ddlModif" runat="server" 
                StoreID="stoModif" 
                    DisplayField="Text" 
                    ValueField="Value"
                    Mode="Local"
                    RegexText="Incorrect Format"
                    MaxLengthText="Max Length reached">
        </ext:ComboBox>
    </Editor>
    In the gripPanel :

    <Listeners>
        <BeforeEdit Handler="ChargeType('ddlModif',grdModif.store.getById(#{grdCaracModif}.getSelections()[0].id).get('Unit'));" />
    </Listeners>
    The store :

    <ext:Store ID="stoModifCarac" runat="server" AutoLoad="false" IgnoreExtraFields="true">
        <Proxy>
            <ext:HttpProxy Method="GET"/>
        </Proxy>
        <Reader>
            <ext:JsonReader Root="Datas" TotalProperty="Total">
                <Fields>
                    <ext:RecordField Name="Text"/>
                    <ext:RecordField Name="Value"/>
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    The ChangeType function :

    ChargeType = function(id, unit) {
        var field = Ext.getCmp(id);
        var load = false;
        
        if (field) {
                //ShapeShifting
                switch(unit) {
                    case 'IP':
                        field.hideTrigger = true;
                        field.editable = true;
                field.maskRe = /[0-9.]/;
                        field.regex = /^([1-9][0-9]{0,1}|1[013-9][0-9]|12[0-689]|2[01][0-9]|22[0-3])([.]([1-9]{0,1}[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){2}[.]([1-9][0-9]{0,1}|1[0-9]{2}|2[0-4][0-9]|25[0-4])$/;
                        field.maxLength = 15;
                    break;
                    case 'Brand':
                        field.hideTrigger = false;
                        field.editable = true;
                field.maskRe = null;
                field.regex = null;
                field.maxLength = 40;
                load = true;
                    break;
                    case 'Int':
                        field.hideTrigger = true;
                        field.editable = true;
                field.maskRe = /[0-9]/;
                field.regex = null;
                field.maxLength = 10;
                    break;
                    default:
                        field.hideTrigger = true;
                        field.editable = true;
                field.maskRe = null;
                field.regex = null;
                field.maxLength = 10;
                    break;
                }
                
                if (load == true) {
                    //Chargement du store
                    champ.store.load({
                        params:{
                            unit:unit
                        }
                    });
                }
            }
        }
    }

    Thank you.

    BrunoC
  2. #2

    RE: Editor cell shapeShifter

    Hi,

    I found a way to do what I wanted but I know that is not the best way to do it.


    I added the following code in the ChangeType function :


    var combo = &#100;ocument.getElementById('ddlModif');
    if (combo) {
    	//Field already created
    	if (!field.hideTrigger) {
    		combo.nextSibling.style.display = '';
    	}
    	else {
    		combo.nextSibling.style.display = 'none';
    	}
    }

    Can you help me finding the right way to do it ?


    Thanl you.


    BrunoC

Similar Threads

  1. Replies: 1
    Last Post: Jul 10, 2012, 11:16 AM
  2. notify the User when the cell editor is not valid
    By ascsolutions in forum 1.x Help
    Replies: 2
    Last Post: Apr 05, 2012, 6:16 PM
  3. notify the User when the cell editor is not valid
    By ascsolutions in forum 1.x Help
    Replies: 2
    Last Post: Mar 20, 2012, 3:42 PM
  4. [CLOSED] Have cell, want to trigger editor and give focus...
    By rthiney in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Dec 21, 2011, 6:01 PM
  5. Replies: 1
    Last Post: Jul 30, 2009, 6:33 AM

Posting Permissions