<ej:Grid ID="OrdersGrid" runat="server" AllowSorting="True" AllowPaging="True" > <Columns> … <ej:Column HeaderText="Order" Template="true" TemplateID="#buttonTemplate" TextAlign="Center" Width="75"/> </Columns> </ej:Grid>
<script type="text/x-jsrender" id="buttonTemplate"> <input type="button" class="Details" name="Details" value="Details"/> </script>
<script type="text/javascript"> $(function () { $(".Details").ejButton({
click: function (e) { var obj = $('#<%= OrdersGrid.ClientID %>').data("ejGrid"); var args = { currentTarget: this.element[0].name, selectedRecord: obj.getSelectedRecords(), selectedIndex: obj.model.selectedRowIndex }; $.ajax({ url: "Default.aspx/ButtonHandler", type: "POST", contentType: "application/json; charset=utf-8", data: JSON.stringify(args)
}) } }); });
[WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] // Return the JSON formatted result public static void ButtonHandler(string currentTarget, List<object> selectedRecord, int selectedIndex) { } |
Hi Pratheep,
Query 1: When click Cancel button in InlineFormTemplate(edit form) - Grid row button disable
We had known issue “Button remains the disable state after cancel the edit action” and we have fixed this error. The fix has been included in our Volume 3 v13.3.0.7 release. So, we suggest you to upgrade to our latest version in order to avoid the reported issue.
And we have resolved the issue using the workaround in product version that you are using. In the workaround, we have removed the disabled attribute using “ActionComplete” event of Grid. Please refer to the following code example.
function complete(args) { . . . if (args.requestType == "cancel") this.getContentTable().find("tr").eq(this.model.selectedRowIndex).find(".Details").removeClass("e-disable").removeAttr("disabled"); . . . } |
Query 2: When click Save button in InlineFormTemplate(edit form) -Grid row button style change
In previous sample, we have rendered the ejButton for the template column in document ready function which was the cause of issue. So, we suggest you to render the ejButton for the template column in “ActionComplete” event of Grid.
Please refer to the following code example.
function complete(args) { . . . OnCreate(); } function OnCreate(args) { $(".Details").ejButton({ click: function (e) { var obj = $('#<%= OrdersGrid.ClientID %>').data("ejGrid"); var args = { currentTarget: this.element[0].name, selectedRecord: obj.getSelectedRecords(), selectedIndex: obj.model.selectedRowIndex }; $.ajax({ url: "WebForm1.aspx/ButtonHandler", type: "POST", contentType: "application/json; charset=utf-8", data: JSON.stringify(args)
}) } }); } |
We have modified the sample that can be downloaded from the below link:
http://www.syncfusion.com/downloads/support/forum/120690/ze/F1206902129282423
Regards,
Saravanan A.
Hi Pratheep,
We are sorry for the inconvenience.
We have initially created the ejButton for the template column using “Create” event of Grid and it has been done in the previous sample. And also using “ActionComplete” event of Grid to recreate the ejButton while performs the grid operations like paging and editing. Please refer to the previous sample and also refer to the following code example.
<ej:Grid ID="OrdersGrid" runat="server" AllowPaging="True" OnServerEditRow="EditEvents_ServerEditRow" OnServerAddRow="EditEvents_ServerAddRow" OnServerDeleteRow="EditEvents_ServerDeleteRow"> . . . <ClientSideEvents ActionComplete="complete" EndAdd="endAdd" EndDelete="endDelete" EndEdit="endEdit" Create="OnCreate" /> . . . </ej:Grid> <script type="text/javascript">
function complete(args) { . . . OnCreate(); }
function OnCreate() { $(".Details").ejButton({ click: function (e) { var obj = $('#<%= OrdersGrid.ClientID %>').data("ejGrid"); var args = { currentTarget: this.element[0].name, selectedRecord: obj.getSelectedRecords(), selectedIndex: obj.model.selectedRowIndex }; $.ajax({ url: "WebForm1.aspx/ButtonHandler", type: "POST", contentType: "application/json; charset=utf-8", data: JSON.stringify(args)
}) } }); }
</script> |
Regards,
Saravanan A.
Hi Pratheep,
Thanks for your update.
We are happy to hear that your issue has been resolved.
Please get back us if you need any further assistance. We will happy to assist you.
Regards,
Saravanan A.