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

  1. #1

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


    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()
        End Sub
        Public Function GetDataInfo() As DataTable
            Dim dt As New DataTable
            Dim dr As DataRow
            Dim i As Integer
            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
                    dr(2) = ""
                    dr(3) = ""
                End If
            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
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <form id="form1" runat="server">
        <ext:ResourceManager ID="resMngr" runat="server" />
        <ext:Viewport ID="Viewport1" runat="server" Layout="Border">
                <ext:Panel ID="pnlCondGrid" runat="server" Region="Center" BodyStyle="background-color:#ededed;"
                    Margins="5,5,5,5" Layout="BorderLayout" Border="true" ButtonAlign="Center">
                        <ext:Toolbar ID="Toolbar4" runat="server" Height="28">
                        <ext:GridPanel ID="grdAllTests" runat="server" Region="Center" BodyStyle="background-color:#DFE8F6"
                            Border="false" AutoExpandColumn="TESTNAME" StripeRows="true">
                                <ext:EditableGrid ID="edgrdTests" runat="server" />
                                <ext:Store ID="storeTests" runat="server" RefreshAfterSaving="Always" OnBeforeStoreChanged="StoreCond_BeforeStoreChanged" OnRefreshData="MyUAData_Refresh">
                                                <ext:RecordField Name="TEST_ID" />
                                                <ext:RecordField Name="TESTNAME" />
                                                <ext:RecordField Name="PAGE_FROM" />
                                                <ext:RecordField Name="PAGE_TO" />
                                        <ext:Parameter Name="start" Value="0" Mode="Raw" />
                                        <ext:Parameter Name="limit" Value="20" Mode="Raw" />
                            <SaveMask ShowMask="true" />
                            <ColumnModel ID="ColumnModel3" runat="server">
                                    <ext:Column Header="Test" DataIndex="TESTNAME">                                   
                                    <ext:Column Header="Page From" DataIndex="PAGE_FROM" Width="100">
                                            <ext:TextField ID="txtPageFrom" runat="server" EnableKeyEvents="true">
                                    <ext:Column Header="Page To" DataIndex="PAGE_TO" Width="100">
                                            <ext:TextField ID="txtPageTo" runat="server" EnableKeyEvents="true">
                                    <ext:CommandColumn Width="100">
                                            <ext:GridCommand Text="Reject" ToolTip-Text="Reject row changes" CommandName="condreject"
                                                Icon="ArrowUndo" />
                                        <PrepareToolbar Handler="toolbar.items.get(0).setVisible(record.dirty);" />
                                <Command Handler="record.reject();" />
                    <ext:Button ID="btnSave" Text="Save" runat="server">
                    <Click Handler="grdAllTests.save()" />
                    <ext:Button ID="btnPopulate" Text = "Populate Ranges" runat="server">
                    <Click OnEvent="PopulatePageRanges" />
    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.
  3. #3
    Hi Daniil,

    Thank you. It is working. I have implemented that approach as in

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