Unable to force Roweditor's "AfterEdit" to fire

  1. #1

    Unable to force Roweditor's "AfterEdit" to fire

    I am trying to change a field that is not displayed in my grid using javascript. Unfortunately the RowEditor does not detect the change and "AfterEdit" does not fire, even when I manually mark the record as "dirty". In my simplified example below, the "AfterEdit" event fires when a row is edited (by double clicking) and the checkbox is checked or unchecked. However, I would expect it to always fire as I am changing a record field and marking the entire record dirty. How can I tell the RowEditor that the record was modified?

    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        
    public class Sample
    {
    
        public int IdField { get; set; }
        public bool VisibleField { get; set; }
        public bool HiddenField { get; set; }
    }
    
    protected void storeTest_refresh(object sender, StoreRefreshDataEventArgs e)
        {
            List<Sample> data = new List<Sample>{new Sample{IdField=1, VisibleField=true, HiddenField=false}
                                                , new Sample{IdField=2, VisibleField=false, HiddenField=true}};
            storeTest.DataSource = data;
            storeTest.DataBind();
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" ViewStateMode="Disabled" />
        <ext:GridPanel ID="gridTest" runat="server" Width="300" Height="300">
            <Store>
                <ext:Store ID="storeTest" runat="server" OnRefreshData="storeTest_refresh" AutoLoad="true">
                    <Proxy>
                        <ext:PageProxy />
                    </Proxy>
                    <Reader>
                        <ext:JsonReader IDProperty="IdField">
                            <Fields>
                                <ext:RecordField Name="IdField" Type="Int" />
                                <ext:RecordField Name="VisibleField" Type="Boolean" />
                                <ext:RecordField Name="HiddenField" Type="Boolean" />
                            </Fields>
                        </ext:JsonReader>
                    </Reader>
                </ext:Store>
            </Store>
            <ColumnModel>
                <Columns>
                    <ext:Column DataIndex="IdField">
                    </ext:Column>
                    <ext:Column DataIndex="VisibleField">
                        <Editor>
                            <ext:Checkbox runat="server">
                                <Listeners>
                                    <show Handler=" var r =gridTest.getRowEditor().record; r.data.HiddenField = !r.data.HiddenField;alert('changed value of hidden field to ' + r.data.HiddenField);r.markDirty()" />
                                </Listeners>
                            </ext:Checkbox>
                        </Editor>
                    </ext:Column>
                </Columns>
            </ColumnModel>
            <Plugins>
                <ext:RowEditor ID="RowEditor1" runat="server" SaveText="Update" ClicksToEdit="2">
                    <Listeners>
                        <AfterEdit Handler="alert('fired afteredit')" />
                    </Listeners>
                </ext:RowEditor>
            </Plugins>
    
        </ext:GridPanel>
    
        </form>
    </body>
    </html>
  2. #2
    Hi,

    The RowEditor plugin works with columns and its editors only.

    You could achieve the requirement overriding a RowEditor's stopEditing method. The RowEditor's sources you can find here:
    <Ext.Net sources root>\Ext.Net\Build\Ext.Net\ux\plugins\roweditor\r oweditor.js

    Though I'm not sure you should override it since there might be a better solution. But I have not got the requirement, so, I can't suggest anything.
  3. #3
    Daniil - Thanks for your speedy reply. I decided to call markDirty() and override the stopEditing method to apply the change and fire "afteredit" when the record is marked dirty.

Similar Threads

  1. [CLOSED] How does "MaskCls" work for "AutoLoad" mask in panel control
    By leon_tang in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Jul 19, 2012, 12:09 PM
  2. Replies: 1
    Last Post: Jun 26, 2012, 11:29 AM
  3. Replies: 5
    Last Post: May 02, 2012, 5:37 PM
  4. Replies: 4
    Last Post: Oct 11, 2011, 2:42 AM
  5. Replies: 2
    Last Post: Sep 02, 2010, 7:15 PM

Tags for this Thread

Posting Permissions