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
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.
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
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
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
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
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
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
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
Hello,
Does anyone got chance to look into this issue?
Regards,
Rahul
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