Hello,
I'm working on putting the finishing touches on a UX update to an application with some WebDataGrid controls. The change is to move away from a fixed form on each screen towards the RowEditing / RowAdding functionality using RowEditingTemplate etc.
I have one event in RowEditingClientEvents working but I think i'm either lucky in how this fires or forcing it manually.
<ig:EditingCore EnableInheritance="true" AutoCRUD="false" EditingClientEvents-RowUpdated="LocationGrid_RowUpdated" EditingClientEvents-RowAdded="LocationGrid_RowAdded"> <Behaviors> <ig:RowEditing EditModeActions-EnableOnKeyPress="false" EditModeActions-MouseClick="None"> </ig:RowEditing> <ig:RowEditingTemplate Enabled="true" EnableInheritance="true" CancelButton="btnCancel" OKButton="btnSave" EditModeActions-RowSelectorMouseClick="None" EditModeActions-MouseClick="None"> <RowEditingClientEvents TemplateClosing="LocationGrid_TemplateClosing" />
This is working when I click save on the rowEditingTemplate Save button as defined here:
<asp:Button ID="btnSave" runat="server" OnClientClick="return" Text="Save" UseSubmitBehavior="False" CssClass="linkButton" /> <asp:Button ID="btnCancel" runat="server" CausesValidation="False" OnClientClick="return" Text="Cancel" UseSubmitBehavior="False" CssClass="linkButton" />
My first question is how to trigger the other (currently not firing ) events like _TemplateOpening, or _TemplateOpened? Is there a property I need to set in the template to force the events to fire correctly? I would like to have some client code run when the template is loading/loaded but i'm having to use the ClientBindings setters to do this currently which is kind of a dirty hack, but it works for now.
Second question, I have an issue where the Save button does correctly fire the TemplateClosing event, and so this is where i'm handling the commit on the client:
function LocationGrid_TemplateClosing(sender, eventArgs) { var isRowValid = validateInput(); var grid = $find("<%=LocationGrid.ClientID%>"); var editingCore = grid.get_behaviors().get_editingCore(); editingCore.commit(); //if nav buttons are clicked, set return state to true for proper navigation postbacks if (actionState == "NextButton" || actionState == "PreviousButton") { actionStateStatus = true; } }
This works fine most of the time, however what i've found in some cases, is that while clicking the Save button in the row editing template form does trigger the closing event and save, there are some other ways to make the template think it's closing that are undesirable. For example, if I partially complete the form and click off the template form on another control that triggers a different function / action, the template closes and fires the event. I get that this makes sense, but how do I either move the commit out of this event to handle it gracefully with my client side validation (validateInput in above code block), OR only trigger the commit when the Save button is clicked? I can save out a flag indicating a button was pressed, but I figured this is probably not the intended behavior for this control so I thought i'd look for advice.
Thanks for reading,
Michael
Infragistics version: Infragistics45.Web.v16.1, Version=16.1.20161.1000
VS 2017; Windows 10; IE 11
Hello Michael,
After investigating this further, I determined that methods could be bound to the TemplateOpening and TemplateOpened events by using RowEditingClientEvents:
<ig:RowEditingTemplate EnableInheritance="True" CancelButton="buttonCancel" OKButton="buttonSave">
<RowEditingClientEvents TemplateClosing="WebDataGrid1_RowEditing_TemplateClosing" TemplateOpened="WebDataGrid1_RowEditing_TemplateOpened" TemplateOpening="WebDataGrid1_RowEditing_TemplateOpening" />
. . .
</ig:RowEditingTemplate>
Regarding your second requirement, validating and committing the changes could be executed in a method bound to the “Save” button:
<asp:Button ID="buttonSave" runat="server" OnClientClick="clickSave();return;" Text="Save" UseSubmitBehavior="False" />
Another possibility would be to check whether saveChanges is set to true on TemplateClosing, if yes, this means that the Save button is clicked and the commit would be executed:
function WebDataGrid1_RowEditing_TemplateClosing(sender, eventArgs)
{
console.log("template is closing");
console.log(eventArgs._saveChanges)
if (eventArgs._saveChanges) {
console.log("Save is clicked and commit would be executed");
}
Below I am attaching a sample, demonstrating the described behavior. Please test it on your side and let me know if you need any further information regarding this matter.
Please keep in mind that according to our support policy Infragistics products have one year of product service releases and three years of developer support. This means that version 16.1 is considered retired and it is no longer eligible for Developer Support Services. This is the reason why the provided sample is in version 20.1.
Regards,
Monika Kirkova,
Infragistics
WebDataGridEditRowTemplate.zip