[CLOSED] EditableGrid Saving issue while populate default values in the grid

  1. #1

    [CLOSED] EditableGrid Saving issue while populate default values in the grid

    Hi,

    I need to implement the saving functionality of EditableGrid where some fields will populate while loading the grid and some fields will enter or modify populated page ranges. I need to save all data information in the grid. Below I just created one example, which one can save data if any changes happened to grid fields, it is saving only modified fields data. I would like to save the complete grid data. Please run the code and add some numbers in the from and to fields, then click save, the message will show the data. Now reload the page and click on "Populate Ranges". This will populate some default values in the fields. Now change any fields and click save will show only changed info, but I need to get both existing and modified data.

    
    <%@ Page Language="VB" %>
    
    <%@ 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">
        Dim populateData As Boolean
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Not Ext.Net.X.IsAjaxRequest Then
                populateData = False
                Call LoadGridInfo()
            End If
        End Sub
        
        Public Sub LoadGridInfo()
            storeTests.DataSource = GetDataInfo()
            storeTests.DataBind()
        End Sub
        
        Public Function GetDataInfo() As DataTable
            Dim dt As New DataTable
            Dim dr As DataRow
            Dim i As Integer
            
            dt.Columns.Add("TEST_ID")
            dt.Columns.Add("TESTNAME")
            dt.Columns.Add("PAGE_FROM")
            dt.Columns.Add("PAGE_TO")
            
            For i = 1 To 10
                dr = dt.NewRow()
                dr(0) = i
                dr(1) = "Test " & i.ToString()
                If populateData Then
                    dr(2) = i
                    dr(3) = i + 1
                Else
                    dr(2) = ""
                    dr(3) = ""
                End If
                
                dt.Rows.Add(dr)
            Next
            
            Return dt
            
        End Function
        
        Public Sub StoreCond_BeforeStoreChanged(ByVal sender As Object, ByVal e As BeforeStoreChangedEventArgs)
            Dim jsonData As String = e.DataHandler.JsonData
            Ext.Net.X.Msg.Alert("Saved", jsonData).Show()
        End Sub
        
        Public Sub MyUAData_Refresh(ByVal sender As Object, ByVal e As StoreRefreshDataEventArgs)
            Call LoadGridInfo()
        End Sub
        
        Public Sub PopulatePageRanges(ByVal sender As Object, ByVal e As DirectEventArgs)
            populateData = True
            Call LoadGridInfo()
        End Sub
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net.Example</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager ID="resMngr" runat="server" />
        <ext:Viewport ID="Viewport1" runat="server" Layout="Border">
            <Items>
                <ext:Panel ID="pnlCondGrid" runat="server" Region="Center" BodyStyle="background-color:#ededed;"
                    Margins="5,5,5,5" Layout="BorderLayout" Border="true" ButtonAlign="Center">
                    <TopBar>
                        <ext:Toolbar ID="Toolbar4" runat="server" Height="28">
                            <Items>
                            </Items>
                        </ext:Toolbar>
                    </TopBar>
                    <Items>
                        <ext:GridPanel ID="grdAllTests" runat="server" Region="Center" BodyStyle="background-color:#DFE8F6"
                            Border="false" AutoExpandColumn="TESTNAME" StripeRows="true">
                            <Plugins>
                                <ext:EditableGrid ID="edgrdTests" runat="server" />
                            </Plugins>
                            <Store>
                                <ext:Store ID="storeTests" runat="server" RefreshAfterSaving="Always" OnBeforeStoreChanged="StoreCond_BeforeStoreChanged" OnRefreshData="MyUAData_Refresh">
                                    <Reader>
                                        <ext:JsonReader>
                                            <Fields>
                                                <ext:RecordField Name="TEST_ID" />
                                                <ext:RecordField Name="TESTNAME" />
                                                <ext:RecordField Name="PAGE_FROM" />
                                                <ext:RecordField Name="PAGE_TO" />
                                            </Fields>
                                        </ext:JsonReader>
                                    </Reader>
                                    <AutoLoadParams>
                                        <ext:Parameter Name="start" Value="0" Mode="Raw" />
                                        <ext:Parameter Name="limit" Value="20" Mode="Raw" />
                                    </AutoLoadParams>
                                </ext:Store>
                            </Store>
                            <SaveMask ShowMask="true" />
                            <ColumnModel ID="ColumnModel3" runat="server">
                                <Columns>
                                    <ext:Column Header="Test" DataIndex="TESTNAME">                                   
                                    </ext:Column>
                                    <ext:Column Header="Page From" DataIndex="PAGE_FROM" Width="100">
                                        <Editor>
                                            <ext:TextField ID="txtPageFrom" runat="server" EnableKeyEvents="true">
                                            </ext:TextField>
                                        </Editor>
                                    </ext:Column>
                                    <ext:Column Header="Page To" DataIndex="PAGE_TO" Width="100">
                                        <Editor>
                                            <ext:TextField ID="txtPageTo" runat="server" EnableKeyEvents="true">
                                            </ext:TextField>
                                        </Editor>
                                    </ext:Column>
                                    <ext:CommandColumn Width="100">
                                        <Commands>
                                            <ext:GridCommand Text="Reject" ToolTip-Text="Reject row changes" CommandName="condreject"
                                                Icon="ArrowUndo" />
                                        </Commands>
                                        <PrepareToolbar Handler="toolbar.items.get(0).setVisible(record.dirty);" />
                                    </ext:CommandColumn>
                                </Columns>
                            </ColumnModel>
                            <Listeners>
                                <Command Handler="record.reject();" />
                            </Listeners>
                        </ext:GridPanel>
                    </Items>
                    <Buttons>
                    <ext:Button ID="btnSave" Text="Save" runat="server">
                    <Listeners>
                    <Click Handler="grdAllTests.save()" />
                    </Listeners>
                    </ext:Button>
                    <ext:Button ID="btnPopulate" Text = "Populate Ranges" runat="server">
                    <DirectEvents>
                    <Click OnEvent="PopulatePageRanges" />
                    </DirectEvents>
                    </ext:Button>
                    </Buttons>
                </ext:Panel>
            </Items>
        </ext:Viewport>
        </form>
    </body>
    </html>
    Last edited by Daniil; Sep 03, 2013 at 3:44 AM. Reason: [CLOSED]
  2. #2
    Hi @rnachman,

    A Store's DataBind() call sets up the initial state which could be interpreted as "nothing to save, everything is already saved". Indeed, the save method sends modified, new or deleted records only.

    According to the requirement you probably need submitting.
    http://examples1.ext.net/#/GridPanel...mit_Two_Grids/
  3. #3
    Hi Daniil,

    Thank you. It is working. I have implemented that approach as in
    http://examples1.ext.net/#/GridPanel...mit_Two_Grids/

Similar Threads

  1. saving dynamically-created controls' values
    By Skizzot223 in forum 1.x Help
    Replies: 1
    Last Post: Apr 16, 2012, 12:54 PM
  2. Replies: 5
    Last Post: Dec 26, 2011, 5:39 AM
  3. Replies: 1
    Last Post: Nov 06, 2011, 10:27 AM
  4. Replies: 2
    Last Post: Sep 19, 2011, 2:05 PM
  5. Combo - Populate with rowindex values
    By Tbaseflug in forum 1.x Help
    Replies: 1
    Last Post: Sep 21, 2009, 11:25 AM

Tags for this Thread

Posting Permissions