Grid BatchEdit mode

4 posts, 0 answers
  1. Zeyad
    Zeyad avatar
    6 posts
    Member since:
    Apr 2011

    Posted 14 Dec 2019 Link to this post

    Hello,

     

    I have a RadGrid with BatchEdit mode, as the following

     

            <telerik:RadGrid runat="server" RenderMode="Lightweight" ID="RadGrid1" Width="100%"
                DataSourceID="SqlDataSourceMain"
                AutoGenerateColumns="false"
                AllowSorting="true" ShowFooter="true"
                Skin="Bootstrap" OnBatchEditCommand="RadGrid1_BatchEditCommand"
    AllowAutomaticDeletes="true" AllowAutomaticInserts="true" AllowAutomaticUpdates="true" ClientSettings-ClientEvents-OnBatchEditCellValueChanged="cellValChanged" ClientSettings-ClientEvents-OnBatchEditClosed="batchEditClosed"
                AllowPaging="true" PageSize="10">
                            
                <MasterTableView CommandItemDisplay="Top" DataSourceID="SqlDataSourceMain" HorizontalAlign="NotSet" InsertItemDisplay="Bottom" DataKeyNames="Id"
                    EditMode="Batch" BatchEditingSettings-EditType="Row">

                    <Columns>
                       
                        <telerik:GridTemplateColumn HeaderText="Type" UniqueName="accountName" DataField="accountName">
                            <ItemTemplate>
                                <%# Eval("accountName") %>
                            </ItemTemplate>
                            <EditItemTemplate>
                                
                                                                 <telerik:RadAutoCompleteBox Width="100%" RenderMode="Lightweight" runat="server" ID="txtAccountName" DataValueField="new_account_number"
                                                                    DataTextField="accName" DropDownWidth="400px" DataSourceID="SqlDataSourceAccounts" Skin="Bootstrap" InputType="Token" Filter="Contains" OnClientEntryAdding="OnClientEntryAddingHandler" OnClientEntryRemoving="clientEntryRem">
                                                                </telerik:RadAutoCompleteBox>
                            </EditItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="150px" />
                            <ItemStyle HorizontalAlign="Center" />
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderText="accountNumber" UniqueName="accountNumber" DataField="accountNumber">
                            <ItemTemplate>
                                     <%# Eval("accountNumber") %>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <telerik:RadAutoCompleteBox RenderMode="Lightweight" Width="100%" runat="server" ID="txtAccountNumber" DataValueField="accName"
                                                                    DataTextField="new_account_number" DropDownWidth="400px" DataSourceID="SqlDataSourceAccounts" Skin="Bootstrap" InputType="Token" Filter="Contains">
                                                                </telerik:RadAutoCompleteBox>
                            </EditItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="150px" />
                            <ItemStyle HorizontalAlign="Center" />
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderText="debitValue" DefaultInsertValue="0" SortExpression="debitValue" UniqueName="debitValue"
                            DataField="debitValue" FooterAggregateFormatString="{0:#,0.000}" Aggregate="Sum">
                            <ItemTemplate>
                                <asp:Label runat="server" ID="lblDebitAmount" Text='<%# Eval("debitValue", "{0:#,0.000}") %>'></asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <span>
                                    <telerik:RadNumericTextBox Width="95px" RenderMode="Lightweight" Skin="Bootstrap" ClientEvents-OnValueChanged="valChangedDebit" runat="server" ID="txtDebitNumeric" Type="Currency">
                                    </telerik:RadNumericTextBox>
                                    <span style="color: Red">
                                        <asp:RequiredFieldValidator ID="rfvAmount"
                                            ControlToValidate="txtDebitNumeric" ErrorMessage="*Required" runat="server" Display="Dynamic">
                                        </asp:RequiredFieldValidator>
                                    </span>
                                </span>
                            </EditItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="100px" />
                            <ItemStyle HorizontalAlign="Right" />
                            <FooterStyle HorizontalAlign="Right" />
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderText="creditValue"  DefaultInsertValue="0" SortExpression="creditValue" UniqueName="creditValue"
                            DataField="creditValue" FooterAggregateFormatString="{0:#,0.000}" Aggregate="Sum">
                            <ItemTemplate>
                                <asp:Label runat="server" ID="lblCreditAmount" Text='<%# Eval("creditValue", "{0:#,0.000}") %>'></asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <span>
                                    <telerik:RadNumericTextBox Width="95px" RenderMode="Lightweight" Skin="Bootstrap" ClientEvents-OnValueChanged="valChangedCredit" runat="server" ID="txtCreditNumeric" Type="Currency">
                                    </telerik:RadNumericTextBox>
                                    <span style="color: Red">
                                        <asp:RequiredFieldValidator ID="rfvAmount2"
                                            ControlToValidate="txtCreditNumeric" ErrorMessage="*Required" runat="server" Display="Dynamic">
                                        </asp:RequiredFieldValidator>
                                    </span>
                                </span>
                            </EditItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="100px" />
                            <ItemStyle HorizontalAlign="Right" />
                            <FooterStyle HorizontalAlign="Right" />
                        </telerik:GridTemplateColumn>
                          <telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow"
                            ConfirmTitle="Delete" HeaderText="Delete" HeaderStyle-Width="50px" 
                            CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
                        </telerik:GridButtonColumn>
                    </Columns>

                </MasterTableView>
            </telerik:RadGrid>

     

    I have outside two labels, one is Debit and the other is Credit. How can I refresh the labels (client-side) to contain the total of each column, the total of Debit to be in the debitlabel and the total of the Credit to be in the creditlabel.

     

    Also, in the autocomplete, when i select a token, it is shown "token;" with additional ';' in the item template, this causes to be also inserted in the database, how can i remove the ';' mark?

     

     

    Many thanks

  2. Eyup
    Admin
    Eyup avatar
    4046 posts

    Posted 18 Dec 2019 Link to this post

    Hi Zeyad, 

     

    You can use the following event handler to achieve this requirement:
    https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/client-side-programming/events/onbatcheditcellvaluechanged

    You can get some ideas from the attached web site sample. You can run it following these steps:

    1. Open Visual Studio
    2. File menu
    3. Open option
    4. Select Web site and target the web site folder.
    5. Include a Bin folder with the Telerik dll assemblies.

    As for the autocompletebox, by default it does not add a semicolon in Token mode:
    https://demos.telerik.com/aspnet-ajax/autocompletebox/examples/programming/addremoveclientside/defaultcs.aspx

    You can try to set the Delimeter property to something else:
    https://www.telerik.com/forums/add-instead-of-semicolon-in-between-items#tEpKENcqvEibfS5ETF1P8g

    I hope these suggestions will prove helpful.

    Regards,
    Eyup
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Zeyad
    Zeyad avatar
    6 posts
    Member since:
    Apr 2011

    Posted 02 Jan 2020 in reply to Eyup Link to this post

    Thanks Eyup, will try the suggested and let you know the results.

     

    Happy new year :)

  4. Eyup
    Admin
    Eyup avatar
    4046 posts

    Posted 06 Jan 2020 Link to this post

    Hello Zeyad,

     

    Happy new year Zeyad :)

    Feel free to try it out and let us know if there are remaining questions.

     

    Regards,
    Eyup
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top