Adding custom Attributes during client side ExtJs creation

  1. #1

    Adding custom Attributes during client side ExtJs creation

    I have a ext:Button on a form. When it is clicked, I perform some custom logic on the client side, and depending upon the result, I may or may not initiate a PostBack.

    Initially, I sat the AutoPostBack on button to true. However, as I was using Handler="myLogic(#{extCtlId})" syntax for registering the Listener to be called, returning "False" from the js function had no effect, and the form always submitted.

    If I use Fn="myLogic", returning False cancelled the PostBack. But I need custom arguments to the js function, so could not use Fn, but Handler.

    If the logic decides to PostBack, I am using the following for initiating it:

    setTimeout('WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("' + document.getElementById(src.id).getAttribute('name') + '", "", true, "", "", false, true))', 0);
    Here is the catch. We need to pass "name" of the form control, not the "id" to this method for firing Click event on the server. Setting autoPostBack to true handles this automatically, but in my situation, I somehow need the name of the element. I have tried everything, but seems like Coolite controls are NOT rendered with their name attribute compared to ASP.NET controls.

    So, I used:

    btn.Attributes.Add("name", btn.UniqueID)
    but again name was NOT rendered. I read somewhere that for dynamic Html controls added to a page, name needs to be passed to createElement. So, basically how do I enable "name" attribute to be rendered on a Coolite control???

  2. #2

    RE: Adding custom Attributes during client side ExtJs creation

    Hi,

    You can use CustomConfig collection of control

    <CustomConfig>
        <ext:ConfigItem Name="name" Value="myName" Mode="Value" />
    </CustomConfig>
    Then check this config parameter

    Ext.getCmp(src.id).name
  3. #3

    RE: Adding custom Attributes during client side ExtJs creation

    Just how could I forget ConfigItem. Anyways, thanx for reminding. On the same page, I am using ConfigItems on so many other places, I just forgot I can use it here too!!!!

Similar Threads

  1. Adding an event to Msg button from a client side?
    By ascsolutions in forum 1.x Help
    Replies: 3
    Last Post: Jan 24, 2012, 11:47 AM
  2. Replies: 8
    Last Post: Dec 10, 2010, 9:21 AM
  3. Replies: 1
    Last Post: Dec 01, 2010, 5:14 PM
  4. Replies: 6
    Last Post: Sep 01, 2009, 1:06 PM
  5. Replies: 1
    Last Post: Jan 25, 2009, 8:33 AM

Posting Permissions