how to update data using ext RowEditor plugin

Page 3 of 3 FirstFirst 123
  1. #21
    I think it's possible.

    You just have updated data on a server side and can use any working mechanism to save that updated data.
  2. #22
    Hi Daniil,

    Well I thought so and did like that. I received the updated data on AfterEdit event handler and submitted the changes to Manager/BLL method to do the DB update. Everything went right without error but there's no change in DB.

    I just don't know why but somehow the update change of store is not affecting DB if I don't initiate the linq DataContext in grid store's BeforeChanged (example is given below)

            protected void storeGrdDivision_BeforeChanged(object sender, BeforeStoreChangedEventArgs e)
            {
                _AMMSDataContext = new AMMSDataContext();
            }
    and then if I don't attach the changed object on BeforeUpdate (example is given below)

            protected void storeGrdDivision_BeforeUpdated(object sender, BeforeRecordUpdatedEventArgs e)
            {
                _Division = e.Object<Division>();
    
                if (_Division != null)
                {
                    _Division.ModifiedBy = UtilityCommon.GetAMMSUserKey();
                    _Division.ModifiedDate = DateTime.Now;
    
                    _AMMSDataContext.GetTable<Division>().Attach(_Division);
                    _AMMSDataContext.Refresh(RefreshMode.KeepCurrentValues, _Division);
                }
            }
    and submit the change on store's AfterChange like this

            protected void storeGrdDivision_AfterChanged(object sender, AfterStoreChangedEventArgs e)
            {
                _AMMSDataContext.SubmitChanges();
            }
    Thought it's working for me now but Im hoping forward that you expert guys there might guide me to a solution to fit my need.

    Thanks for your help
  3. #23
    I think a DataContext instance is required to update a DB.

    I should clarify the following things:

    1. The OnBeforeStoreChanged event is fired when there was any change (-s) in a Store and the Store's method .save() is called (or grid.save()).

    2. So, when the RowEditor's AfterEdit is fired, then a OnBeforeStoreChanged handler is not executed.

    Here is the example demonstrating what I said.

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store store = this.GridPanel1.GetStore();
                store.DataSource = new object[] 
                { 
                    new object[] {"test1", "test2" },
                    new object[] {"test3", "test4" },
                    new object[] {"test5", "test6" },
                };
                store.DataBind();
            }
        }
    
        protected void Store_BeforeStoreChanged(object sender, BeforeStoreChangedEventArgs e)
        {
            X.Js.Call("addlog", "<br/>Store_BeforeStoreChanged");
        }
    
        protected void RowEditor_AfterEdit(object sender, DirectEventArgs e)
        {
            X.Js.Call("addlog", "<br/>RowEditor_AfterEdit : " + e.ExtraParams["data"]);
        }
    </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>
        
        <script type="text/javascript">
            var addlog = function (html) {
                Ext.get("log").insertHtml("beforeEnd", html);
            };
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
                <Store>
                    <ext:Store runat="server" OnBeforeStoreChanged="Store_BeforeStoreChanged">
                        <Reader>
                            <ext:ArrayReader>
                                <Fields>
                                    <ext:RecordField Name="test1" />
                                    <ext:RecordField Name="test2" />
                                </Fields>
                            </ext:ArrayReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column Header="Test1" DataIndex="test1">
                            <Editor>
                                <ext:TextField runat="server" />
                            </Editor>
                        </ext:Column>
                        <ext:Column Header="Test2" DataIndex="test2" />
                    </Columns>
                </ColumnModel>
                <Plugins>
                    <ext:RowEditor runat="server">
                        <DirectEvents>
                            <AfterEdit OnEvent="RowEditor_AfterEdit">
                                <ExtraParams>
                                    <ext:Parameter Name="data" Value="r.data" Mode="Raw" Encode="true" />
                                </ExtraParams>    
                            </AfterEdit>
                        </DirectEvents>
                    </ext:RowEditor>
                </Plugins>
            </ext:GridPanel>
            <ext:Button runat="server" Text="Save">
                <Listeners>
                    <Click Handler="GridPanel1.save();" />
                </Listeners>
            </ext:Button>
            <div id="log"></div>
        </form>
    </body>
    </html>
    So, I think you can use these two options:

    1. Save updated data within RowEditor's AfterEdit DirectEvent handler. Creating a DataContext instance is required.

    2. Calling
    grid.save()
    within RowEditor's AfterEdit client side listener to force OnBeforeStoreChanged event.
  4. #24
    Thanks Daniil,

    I will try the approach you have suggested.

    Regards
  5. #25

    Updating

    Quote Originally Posted by reezvi View Post
    Hello there,
    Im very new to ext.net controls. I was trying to use RowEditor plugin for grid panels. New data entries are done through a form and I wanted to update selected row data changes when user edits data and clicks the 'Update' button in RowEditor. I want to do either of the two approaches -

    1. On update button click, calling a DirectMethod to submit the changes to DB.
    2. Submit the update changes to DB using ObjectDataSource on RowEditor's button event.

    I have checked example of RowEditor in ext.net examples but found it's only updating the store. Couldn't find any example to suit my query. I'll be very helpful if any one can provide me an example (hopefully for both approaches) using RowEditor.

    Im in real urgency here and looking forward for your assistance.

    Thanks in advance.
    Hi
    M new to this ext.net.Plz tel me how to update gridpanel data to database after editing row. Need urgently.can one know
    Thanks in advance
  6. #26
    Quote Originally Posted by sneha View Post
    M new to this ext.net.Plz tel me how to update gridpanel data to database after editing row. Need urgently.can one know
    Hi,

    Please clarify did you see the example in the post #23?

    I think it should be enough. You just should save "data" to a database.
  7. #27
    Quote Originally Posted by Daniil View Post
    Hi,

    Please clarify did you see the example in the post #23?

    I think it should be enough. You just should save "data" to a database.
    Thanks for ur reply.
    Ya i saw but i want to use stored procedures to update.
  8. #28
    You should be able to call a store procedure from code behind.
Page 3 of 3 FirstFirst 123

Similar Threads

  1. RowEditor Plugin for GridPanel
    By bright in forum 1.x Help
    Replies: 0
    Last Post: Feb 17, 2012, 3:04 PM
  2. Custom button on RowEditor plugin
    By mirzasa in forum 1.x Help
    Replies: 2
    Last Post: May 17, 2011, 10:42 AM
  3. [CLOSED] Styles on RowEditor plugin (again?)
    By sadaf in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Mar 16, 2011, 8:55 AM
  4. RowEditor plugin and resizing columns
    By Daniil in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 15, 2011, 8:38 AM
  5. Plugin roweditor only for update grid
    By Fabrizio in forum 1.x Help
    Replies: 1
    Last Post: Jul 09, 2010, 12:55 PM

Posting Permissions