[CLOSED] how to have a Dynamic textfield in beforebind

  1. #1

    [CLOSED] how to have a Dynamic textfield in beforebind

    I found the below code in the forum for having a dynamic combobox inside a grid during the beforebind event.:

    <script>
            var onBeforeBind = function(column, e) { // "e" contains "config", "grid", "record", "rowIndex".
                e.config = {
                    xtype: "netmulticombo",
                    queryMode: "local",
                    displayField: "text",
                    store: {                     
                        /* configure a store as needed */ 
                        model: Ext.define("Model" + e.rowIndex, {
                            extend: "Ext.data.Model",
                            fields: [ "text" ]
                        }),
                        data: [{
                            text: "Item1"
                        }, {
                            text: "Item2"
                        }]
                    }
                };
            };
        </script>
    Can someone provide me the code for having a dynamic textfield. Based on the row index I want to set that row as an editable field.
    Last edited by Daniil; May 19, 2015 at 10:32 PM. Reason: [CLOSED]
  2. #2
    Hi @arjunrvasisht,

    Please use:
    e.config = {
        xtype: "textfield"
    };
  3. #3
    Thanks Daniil,

    How do i have a render event for a dynamically created text field.

     <ext:TextField ID="TextField1" runat="server">
                                                        <Listeners>
                                                            <Render Fn="disableTier3DisplayName"></Render>
                                                            <Blur Handler="setT3BlurEvenCall();validateDistinctT3(this,#{storeDistinctT3});validateDistinctT3grdTier3Mapping(this,#{str3TierMapping});validateDistinctT3withOthers(this,#{strNewTier3});"></Blur>
                                                            <Change Fn="checkForT3edit"></Change>
                                                            <AfterRender Handler="this.el.dom.setAttribute('onPaste', 'return false');" />
                                                        </Listeners>
                                                    </ext:TextField>
    Like the above text field I have Render, blur change and after render event written for a text field. How do I write these events for the dynamically created one. This is how i have created dynamically:

     e.config = {
                        xtype: "textfield",
                        queryMode: "local",
                        displayField: "text",
                        store: {
                            /* configure a store as needed */
                            model: Ext.define("Model" + e.rowIndex, {
                                extend: "Ext.data.Model",
                                fields: ["text"]
                            })
                        }
                    };
  4. #4
  5. #5
    Thanks Daniil,

    As per the link u have suggested I could code like below:

     e.config = {
                        xtype: "textfield",
                        queryMode: "local",
                        displayField: "text",
                        // readOnly : true,
                        disabled : true, 
                        //selectable : false,
                        listeners : {
                            change : {
                                fn : checkForT3OtherEdit
                            },
                            afterrender : {
                                handler : this.el.dom.setAttribute('onPaste', 'return false')
                            }
                        },
                        store: {
                            /* configure a store as needed */
                            model: Ext.define("Model" + e.rowIndex, {
                                extend: "Ext.data.Model",
                                fields: ["text"]
                            })
                        }
                    };
                }
    The change event inside the listener is working fine but the code which i have in handler is not working. I didn't find the syntax to write after render event and handler in the link u have suggested. Could you please tell me how do I write a after render and handler event.
  6. #6
    It should be
    afterrender: {
        fn: function() { 
            this.el.dom.setAttribute('onPaste', 'return false');
        }
    }
  7. #7
    Thanks Daniil, it worked fine. One last thing. How do i write the below blur event:

     <Blur Handler="setT3BlurEvenCall();validateDistinctT3(this,#{storeDistinctT3});validateDistinctT3Others(this,#{str3TierMapping});"></Blur>
    I tried something like this:

     blur : {
                                fn: function(){
                                    setT3OtherBlurEvenCall();validateDistinctT3OthersName(this,#{storeDistinctNewTier3});
                                }                            
                            }
    But it dint work.!!
  8. #8
    One of the easiest ways to learn the JavaScript syntax is to view the JavaScript generated by Ext.NET. Take the configuration that is working, then view the source and search for your code in the generated source.

    Hope this helps.
    Geoffrey McGill
    Founder

Similar Threads

  1. [CLOSED] Get Dynamic TextField Text...
    By gs_user in forum 2.x Legacy Premium Help
    Replies: 8
    Last Post: Apr 24, 2012, 3:56 AM
  2. Dynamic TextField KeyUP Event
    By archana in forum 1.x Help
    Replies: 0
    Last Post: Oct 21, 2011, 6:23 AM
  3. Dynamic create a TextField and Button
    By cnet2001 in forum 1.x Help
    Replies: 3
    Last Post: Dec 17, 2010, 1:16 AM
  4. Replies: 1
    Last Post: Dec 16, 2010, 12:08 PM
  5. FindControl for dynamic textfield failing
    By venuc in forum 1.x Help
    Replies: 8
    Last Post: Feb 03, 2010, 11:40 AM

Tags for this Thread

Posting Permissions