I have Asp.net application using UltraWebGrid but want to upgrade to WebHierarchicalDataGrid. I am now evaluating Infragistics Ultimate 2014 vol. 1.
My application has 4 bands and only the 4th band is allowed to edit when I have pressed "Edit" button. Then, data will be saved in database only when I have pressed "Save" button. The columns in WebHierarchicalDataGrid are written in code behind using C#. Therefore, I create EditingCore and CellEditing behaviors in RowIslandDataBinding() function.
Here is my grid in aspx:
<ig:WebHierarchicalDataGrid ID="gvBudgetTree" runat="server" AutoGenerateBands="False" AutoGenerateColumns="False" Height="1350px" Width="1050px" OnInitializeRow="gvBudgetTree_InitializeRow" OnRowIslandDataBinding="gvBudgetTree_RowIslandDataBinding" OnRowUpdating="gvBudgetTree_RowUpdating" OnRowIslandDataBound="gvBudgetTree_RowIslandDataBound" OnRowUpdated="gvBudgetTree_RowUpdated" CssClass="ighg_Container" EnableDataViewState="True" EnableAjax="True" EnableViewState="true"> <Behaviors> <ig:Paging EnableInheritance="false" PagerMode="Numeric" Enabled="true"></ig:Paging> </Behaviors> </ig:webhierarchicaldatagrid>
In C#,
PageLoad() - Prepare dataset, prepare grid columns, bind data
InitializeRow() - prepare the coloring in columns.
RowIslandDataBinding() - create EditingCore and CellEditing behaviors
RowIslandDataBound() - testing for event firing
RowUpdating() - testing for event firing
RowUpdated() - testing for event firing
However, I found that RowUpdating() and RowUpdated() are never fired. Do I miss anything? Also, I would like to know my approach is correct (create behavior in RowIslandDataBinding())?
Thanks!
Hello Michelle and welcome to our forums!
I'd like to ask you if there is any particular reason to create the behaviors this way?
Also, why are you hooking to the Row events like this?
I believe that if you can tell me your final goal and what you are trying to achieve I might get a better sense of what you are doing and what other ways you can use to achieve this.
We'll be waiting for your feedback, thank you.
Hello Michelle,
Regarding subscribing the RowUpdated event, I would suggest doing this on the page's Init stage. The behaviors themselves can in this case be initialized onInitializeBand(the EditingCore can be initialized for the whole band rather than individual row islands). I am attaching a small sample demonstrating this scenario.
Please feel free to contact us with any questions.
Hello Petar,
Thanks for your sample. I have tried to modify your sample to add a button to enable/disable cell editing bahavior but failed.
Thank you for your reply.
The child behaviors need to be disabled or enabled at particular stages of the control lifecycle. In this case I would suggest handling the BandViewStateLoaded event and checking the request event target to determine which button caused the postback. I am attaching a sample illustrating this. Note that the buttons in this case require to have their useSubmitBehavior property in order to use __doPostBack instead of submit (otherwise the request event target is empty).
Please do not hesitate to contact me if you have any questions.
Hi Petar,
I have tried your code but cell can still be edited when I have pressed "Disable Editing".
Also, regarding to RowUpdate(), as my WebHierarchicalDataGrid is created dynamically in code, I cannot hook event in OnInit() function. Could you suggest another way to do so? Thanks!
I have tested my sample once more using 14.1 build 2150 and the disable button successfully disables the editing core of the fourth band under IE11, FF and Chrome. Please let me know if you are using another version or a different browser. Also can you confirm that clicking the Disable button successfully returns the desired Eventtarget on BandViewStateLoaded?
Regarding subscribing the RowUpdate handler, I would suggest using the grid's own Init event for the purpose.
Please let me know if this helps.
Please feel free to contact me if you have any further questions regarding this matter.
Sorry for my late reply.
I found that I was using Version=14.1.20141.1015. Is there any big difference between mine and yours? This is the free trail version downloaded from your site.
For browser, as we need to support out client from IE8 to IE11, I am using IE8 for development and perform testing on other versions once when development is ready.
FYI. My company is going to purchase Infragistics ASP.NET 2014 Vol. 1 but it takes time :(
I will try your suggestion to hook RowUpdateHandler during band init. Will let you know the result. Thanks!
After trying to hook RowUpdateHandler during band init, the result is negative. :(I am thinking to update the data source in client side as I can hook and receive CellEditing event. I add one more column to my data source and initially set all as 0. Once I received the CellEditing event in client side, I set the value in this extra column to 1 such that when I clicked Save button, I can check the value in this extra column to determine whether to save the data to DB. But how can I get / set the value in client side?
Besides, my forth band is composed of the followings:
1. Image button2. Checkbox3. Text4. Dropdown box5. Dropwdown box6. Textbox7. Button
These elements also depend on View / Edit to show or hide and depend on status to become editable. Do you think it is better to postback when Edit button is clicked to redraw and rebind the grid?
The WHDG (and WebDataGrid) can be updated on the client through the editing core, however these changes still need to be committed through the grid's EditingCore. Clientside editing is not supported with this grid - for that purpose I would suggest using the IgniteUI igHierarchcialGrid.
As it seems that your band consists entirely of TemplatedFields, it would be helpful to see a working sample illustrating the scenario and how the datasource fields are bound through the template controls. This would allow me to provide you with additional feedback regarding this scenario.
We used stored procedures to retrieve data from SQL Server and then bind the dataset to WHDG. I am not so sure how can I share my work to you. Does it help if I share the source codes to you? :(