- Home
- Forum
- ASP.NET Web Forms
- ASP.GRID <ej:Grid CHANGE HEADER TEXT AFTER DATABOUND
ASP.GRID <ej:Grid CHANGE HEADER TEXT AFTER DATABOUND
Thanks for contacting Syncfusion support.
Query 1:”Change the HeaderText after databound”
We have achieved your requirement “change the header text name” using dataBound event and created a sample. Please refer to the code example, documentation and sample,
Code example:
|
<ej:Grid ID="Grid1" AllowSorting="true" AllowPaging="True" AllowScrolling="True" AllowResizing="True" EnableRowHover="true" AllowReordering="false" Locale="en-US" AllowMultiSorting="false" AllowGrouping="True" runat="server"> <PageSettings PageSize="15" /> <ClientSideEvents ToolbarClick="onToolBarClick" DataBound="dataBound"/> </ej:Grid> <code something> function dataBound(args) {
this.model.columns[0]['headerText'] = "Modified headerText name";
this.columns(args.model.columns); } |
Sample:HTchangeinDBevent
Help documentation:http://help.syncfusion.com/js/api/ejgrid#methods:columns
Query 2:”Save the grid values after button submit”
Please share the following details, it would be helpful for us to provide the better solution as earliest,
Regards,
Venkatesh Ayothiraman.
Query 2:”Save the grid values after button submit”
Please share the following details, it would be helpful for us to provide the better solution as earliest,
Regards
Nikos
Thanks for your update.
Query 1:”Can I do this server side?”
Yes, you can change the header text in server side using onDataBound server side event. Please refer to the below code example,
|
<aspx.cs page> public void Databound(object sender, System.EventArgs e) { this.Grid1.Columns[0].HeaderText = "Modify"; } |
Query 2:”Save the grid values in server side”
We have achieved your requirement using server side event onServerBatchEditRow and get the updated values from event arguments. We get a modified value as arrayList, we need to convert the array to our corresponding instance when we edit, delete or insert a record from client side. So, now you are able to save the values into the datasource. For your convenience, we have created a sample and refer to the code example,
Code example:
|
public void batchChanges(object sender, GridEventArgs e) {
Orders ord = new Orders(); BatchChanges batch = new BatchChanges();
ArrayList changed = ((ArrayList)((Dictionary<String, Object>)e.Arguments["batchChanges"])["changed"]);
ArrayList added = ((ArrayList)((Dictionary<String, Object>)e.Arguments["batchChanges"])["added"]);
ArrayList deleted = ((ArrayList)((Dictionary<String, Object>)e.Arguments["batchChanges"])["deleted"]); foreach (Dictionary<string, object> source in changed) batch.changed.Add(ObjectExtensions.ToObject<Orders>(source)); foreach(Dictionary<string, object> source in added) batch.added.Add(ObjectExtensions.ToObject<Orders>(source)); foreach (Dictionary<string, object> source in deleted) batch.deleted.Add(ObjectExtensions.ToObject<Orders>(source)); <Code something> public static class ObjectExtensions { public static T ToObject<T>(this Dictionary<string, object> source) where T : class, new() { T someObject = new T(); Type someObjectType = someObject.GetType();
foreach (KeyValuePair<string, object> item in source) { someObjectType.GetProperty(item.Key).SetValue(someObject, item.Value, null); }
return someObject; } } |
Sample:SyncfusionASPNETApplication2
Regards,
Venkatesh Ayothiraman.
- 3 Replies
- 2 Participants
-
NI NiKOS
- Mar 16, 2016 03:11 PM UTC
- Mar 18, 2016 01:22 PM UTC