how to save data from lable which is used as editor

  1. #1

    how to save data from lable which is used as editor

    HI,

    I am using label with editor and when user double click on label he can edit contents and edited contents is save on the current page like
       
           <ext:Label 
                 ID="Label4" 
                 runat="server" 
                Cls="editable" 
                Icon="NoteEdit"
                OverCls="editable-over"
                Text="Double click editing">
            <Editor>
                <ext:Editor ID="Editor3" runat="server" AutoSize="Width" ActivateEvent="dblclick" />                                                
           </Editor>
    </ext:Label>
    ...but when i get the label text it give me the old text not the edited text. i m geting text like
        protected void CompleteEdit(object sender, AjaxEventArgs e)
           {
               string data = Label4.text.ToString();
           }
    . Can any body tell me how can i save the edited text ?
  2. #2

    RE: how to save data from lable which is used as editor

    Hi Sameera,

    Where is CompleteEdit being configured? Can you show how/where you configure CompleteEdit?


    Geoffrey McGill
    Founder
  3. #3

    RE: how to save data from lable which is used as editor

    Here's a full .aspx sample demonstrating how to pass the new value in the ExtraParams to the server-side Complete event handler.

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
    
    <script runat="server">
        protected void Editor1_Complete(object sender, DirectEventArgs e)
        {
            X.Msg.Notify("New Value", e.ExtraParams["newvalue"].ToString()).Show();
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Ext.NET Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:Label runat="server" Text="Double Click to Edit">
                <Editor>
                    <ext:Editor runat="server" AutoSize="Width" ActivateEvent="dblclick">
                        <DirectEvents>
                            <Complete OnEvent="Editor1_Complete">
                                <ExtraParams>
                                    <ext:Parameter Name="newvalue" Value="value" Mode="Raw" />
                                </ExtraParams>
                            </Complete>
                        </DirectEvents>
                    </ext:Editor>
                </Editor>
            </ext:Label>
        </form>
    </body>
    </html>
    The above code is written for the v1.0 release, although the process is near identical for 0.8.x. Renaming "DirectEvent" to "AjaxEvent" would be required.

    Hope this helps.

    Geoffrey McGill
    Founder
  4. #4

    RE: how to save data from lable which is used as editor

    Hi,

    Thanks for the reply...its works :)..
    one more thing i have more then 1 lable on same panel so is must to use separate onevent for all ? if a use same method for all labels it giving error of other lables... is there any way to use them with same method?
  5. #5

    RE: how to save data from lable which is used as editor

    Here's a pretty advanced sample which demonstrates linking one <ext:Editor> to many <ext:Label> components and passing the Labels updated value back to the server for processing.

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
    
    <script runat="server">
        [DirectMethod(Namespace="CompanyX")]
        public void Update(string id, string newValue)
        {
            X.Msg.Notify(id, newValue).Show();
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Ext.NET Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:Label ID="EditLabel1" runat="server" Text="Double Click to Edit" />
            
            <br />
            <br />
            
            <ext:Label ID="EditLabel2" runat="server" Text="Or, edit this Label" />
            
            <ext:Editor 
                runat="server" 
                Target="${[id^=EditLabel] .x-label-value}" 
                ActivateEvent="dblclick">
                <Listeners>
                    <Complete Handler="CompanyX.Update(editor.boundEl.parent().id, value);" />
                </Listeners>
            </ext:Editor>
        </form>
    </body>
    </html>
    The real hack in there is obviously the .Taget property which is set with a DomQuery string. This particular DomQuery string can be explained as follows...

    1. Find all elements on the page which have an "id" attribute with a value that starts with "EditLabel". This will find both "EditLabel1" and "EditLabel2".

    2. Then find the .x-label-value element inside the element from #1.

    The ${...} syntax is a shortcut for an Ext.select function which takes the DomQuery string as a parameter. The Ext.select will return a list of elements to attach the Editor to. In this case, the two <ext:Label>'s.

    The ajax callback to the server is handled by a custom DirectMethod, although you could fire a <Complete> DirectEvent as well. Either one will work.

    The first parameter passed to the Update method is the <ext:Label>'s client-side ID. Second parameter is the new value for the Label.

    More information for DomQuery available at the following location, see

    http://www.extjs.com/deploy/dev/docs...s=Ext.DomQuery

    This is a much more advanced sample than we typically provide, but it does demonstrate a very powerful technique and considering how much functionality is actually happening behind the scenes here, uses very little code.

    Hope this helps.
    Geoffrey McGill
    Founder
  6. #6

    RE: how to save data from lable which is used as editor

    Thanks its realy a advance example but very much helpful thanks...

Similar Threads

  1. Save gridpanel data
    By Vaishali in forum 1.x Help
    Replies: 0
    Last Post: Feb 20, 2012, 6:33 AM
  2. Save data from two GridPanels
    By Dominik in forum 1.x Help
    Replies: 15
    Last Post: May 11, 2011, 2:43 PM
  3. how to save the changings done by editor
    By pearl in forum 1.x Help
    Replies: 0
    Last Post: Sep 30, 2009, 1:43 AM
  4. How to save the many data
    By wkcode in forum 1.x Help
    Replies: 1
    Last Post: Feb 28, 2009, 3:39 AM
  5. Data back on a Store.save()
    By Dave.Sanders in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Sep 03, 2008, 1:03 PM

Posting Permissions