This is a migrated thread and some comments may be shown as answers.

Batch Editing not working properly

11 Answers 427 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Enix
Top achievements
Rank 1
Enix asked on 30 Jun 2016, 02:15 AM

Hi all,

I have codes below at javascript:

var grid = $find("<%=RadGrid1.ClientID %>");

var batchManager1 = grid.get_batchEditingManager();

var hasChanges = batchManager1.hasChanges(grid.get_masterTableView());

if(hasChanges) {

    grid.get_batchEditingManager().saveChanges(grid.get_masterTableView());

}

else{

args.get_

 

 

I have code below at code behind:
protected void RadGrid1_BatchEditCommand(object sender, GridBatchEditingEventArgs e)
{
    foreach (GridBatchEditingCommand command in e.Commands)
    {
        Hashtable newValues = command.NewValues;
        Hashtable oldValues = command.OldValues;
        string newFirstName = newValues["FirstName"].ToString();
    }
}

11 Answers, 1 is accepted

Sort by
0
Enix
Top achievements
Rank 1
answered on 30 Jun 2016, 02:17 AM

Sorry. I accidentally click post. Please ignore post above.

I have codes below at javascript:
var grid = $find("<%=RadGrid1.ClientID %>");
var batchManager1 = grid.get_batchEditingManager();
var hasChanges = batchManager1.hasChanges(grid.get_masterTableView());
if(hasChanges) {
    grid.get_batchEditingManager().saveChanges(grid.get_masterTableView());
}
else{
args.set_cancel(true);

window.close();

}


I have code below at code behind:
protected void RadGrid1_BatchEditCommand(object sender, GridBatchEditingEventArgs e)
{
    foreach (GridBatchEditingCommand command in e.Commands)
    {
        Hashtable newValues = command.NewValues;
        Hashtable oldValues = command.OldValues;
        string newFirstName = newValues["FirstName"].ToString();
    }
}

 

The problem here is sometimes it will not trigger RadGrid1_BatchEditCommand. Please help.

0
systems
Top achievements
Rank 1
answered on 30 Jun 2016, 06:24 AM
Hello, I have another problem regrading RadGrid Batch Edit mode as below - 

Here, I have attached some screen shots for reference, from the demo given on link;
http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/batch-editing/defaultcs.aspx 

I want to implement the same funtionality for multiple columns Validations of RadGird during batch edit add new record action.
The same have been shown in your demo for validating 'UnitPrice' column. 
I have gone through the code but i didnt find the code required for validation of "PRODUCTNAME","UNITPRICE" columns while saving newly added record.

Please, help me to find the code required and achive the same functionality.

Thanks.

Rahul
0
Enix
Top achievements
Rank 1
answered on 01 Jul 2016, 08:16 AM
My telerik version is Telerik UI for ASP.NET AJAX Q2 2016
0
Kostadin
Telerik team
answered on 04 Jul 2016, 12:09 PM
Hello,

Both columns PRODUCTNAME and UNITPRICE have a column validation. Please check out the following code snippet.
<telerik:GridBoundColumn DataField="ProductName" HeaderStyle-Width="210px" HeaderText="ProductName" SortExpression="ProductName"
    UniqueName="ProductName">
    <ColumnValidationSettings EnableRequiredFieldValidation="true">
        <RequiredFieldValidator ForeColor="Red" Text="*This field is required" Display="Dynamic">
        </RequiredFieldValidator>
    </ColumnValidationSettings>
</telerik:GridBoundColumn>
 
<telerik:GridTemplateColumn HeaderText="UnitPrice" HeaderStyle-Width="80px" SortExpression="UnitPrice" UniqueName="TemplateColumn"
    DataField="UnitPrice">
    <ItemTemplate>
        <asp:Label runat="server" ID="lblUnitPrice" Text='<%# Eval("UnitPrice", "{0:C}") %>'></asp:Label>
    </ItemTemplate>
    <EditItemTemplate>
        <span>
            <telerik:RadNumericTextBox RenderMode="Lightweight" Width="55px" runat="server" ID="tbUnitPrice">
            </telerik:RadNumericTextBox>
            <span style="color: Red">
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1"
                    ControlToValidate="tbUnitPrice" ErrorMessage="*Required" runat="server" Display="Dynamic">
                </asp:RequiredFieldValidator>
            </span>
        </span>
    </EditItemTemplate>
</telerik:GridTemplateColumn>

Regards the Enix's question please make sure you have some changes before you save them. Also you might experience such issue when you are using a template columns. I would recommend you to examine the following help article which elaborates more on handling such scenarios. 

Regards,
Kostadin
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
systems
Top achievements
Rank 1
answered on 05 Jul 2016, 06:44 AM
Thank you for your reply, we tried the same as below, however it works only for template column and not GridBound column.

 

<telerik:RadGrid ID="RadGridTitle"  Height="360px"
                runat="server" Width="550"  PageSize="20" OnNeedDataSource="RadGridTitle_NeedDataSource" OnBatchEditCommand="RadGridTitle_BatchEditCommand"
                CellSpacing="0" GridLines="None" AllowMultiRowEdit="false" AllowPaging="True" AllowSorting="false">
                <MasterTableView CommandItemDisplay="Top" AutoGenerateColumns="false" ShowFooter="True" EditMode="Batch"
                    InsertItemDisplay="Top" InsertItemPageIndexAction="ShowItemOnFirstPage" DataKeyNames="TitleId">
                    <BatchEditingSettings EditType="Cell"/>
                    <Columns>                       
                        <telerik:GridBoundColumn DataField="TitleId" UniqueName="TitleId" HeaderText="Title Id" meta:Resourcekey="TitleId">
                            <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                <RequiredFieldValidator ForeColor="Red" Text="*Required" Display="Dynamic"></RequiredFieldValidator>
                            </ColumnValidationSettings>
                        </telerik:GridBoundColumn>
                        <telerik:GridTemplateColumn DataField="TitleName" UniqueName="TitleName" HeaderText="Title" meta:Resourcekey="TitleName">
                            <ItemTemplate>                               
                                <telerik:RadTextBox ID="txtTitleName1" runat="server" Text='<%# Eval("TitleName") %>' ClientIDMode="Static" CssClass="textBox1" >
                                </telerik:RadTextBox>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <telerik:RadTextBox ID="txtTitleName" runat="server" Text='<%# Eval("TitleName") %>' ClientIDMode="Static" CssClass="textBox" >
                                    <ClientEvents OnKeyPress="AlphabetOnly" OnValueChanged="ValidateDuplicateData"/>
                                </telerik:RadTextBox>
                                <div style="display:block; color:red;"><asp:RequiredFieldValidator ID="rfvtitlename" runat="server" ErrorMessage="Please enter title name." ControlToValidate="txtTitleName" Display="Dynamic" meta:ResourceKey="rfvtitlename" /></div>                              
                            </EditItemTemplate>
                        </telerik:GridTemplateColumn>
                    </Columns>
                </MasterTableView>
                <ClientSettings>
                    <Scrolling AllowScroll="true" ScrollHeight="350px" />
                </ClientSettings>
            </telerik:RadGrid>

Hi,

Here is my code,

When I add new record, validation for column "TitleId" does not work, where as for column "TitleName" validation works properly.

Is there any client side coding and Javascript/jquery libraries required ?

Regards,

Rahul

0
Kostadin
Telerik team
answered on 08 Jul 2016, 06:21 AM
Hello Rahul,

I prepared a small sample and attached it to this thread. As you can see the required field validator is working correctly for bound column. Could you please check out the attached sample and let me know how it differs from your real setup? Additionally please make sure you are not receiving any client side exception which might prevent displaying the validator on your end.

Regards,
Kostadin
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
systems
Top achievements
Rank 1
answered on 11 Jul 2016, 07:20 AM
Hello Kostadin,

Thanks for replying.

Your sample code works fine as an individual page in separate solution.

If I integrate the same page in our project validation does not works for Newly added record. 

Also, I do not get any client side/server side exception.

Could you please suggest what extra settings I need to check for validation to work on my page.

Regards,
Rahul

0
Kostadin
Telerik team
answered on 14 Jul 2016, 05:38 AM
Hi Rahul,

I am afraid based on the provided information it will be hard to pinpoint the cause for this issue. Could you please try isolating the issue in a small runnable sample in order to investigate it locally? Additionally could you please check whether the validation is working for the other edit types?

Regards,
Kostadin
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
systems
Top achievements
Rank 1
answered on 14 Jul 2016, 09:22 AM
Hello Kostadin,

Thank you for reply.

Here I have attached the sample code. 

In this code I have page hierarchy as .aspx page - > .ascx page(loading dynamically on button click). In .ascx file I have RadGrid in BatchEdit mode having BoundColumns for which RequiredFieldValidator works properly.

My live project scenario is slightly different from this.

I have page hierarchy as .master page -> .aspx page - > .ascx page(loading dynamically). In .ascx file I have RadGrid in BatchEdit mode having BoundColumn for which RequiredFieldValidator does not work(I cannot provide live project code).

If I integrate same page given in above sample code with my live project it doesnot work.

Do you think page level hierarchy is affecting the funtionality?

Hope you got exact problem.

Regards,
Rahul
0
systems
Top achievements
Rank 1
answered on 21 Jul 2016, 04:40 AM

Hello,

Does anyone got chance to look into this issue?

Regards,

Rahul

0
systems
Top achievements
Rank 1
answered on 25 Jul 2016, 04:30 AM

Hello Konstadin & Team,

Kindly advise us on the issues raised by Rahul. We have kind of stuck here due to this trange behavior.

Appreciate your early advise on this pls.

Thanks,

Chetan

Tags
Grid
Asked by
Enix
Top achievements
Rank 1
Answers by
Enix
Top achievements
Rank 1
systems
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or