<ej:grid id="FlatGrid" runat="server" allowscrolling="true" AllowPaging = "true" > <Columns> <ej:Column Field="OrderID" HeaderText="Order ID" IsPrimaryKey="true" TextAlign="Right" Width="90"> </ej:Column> <ej:Column Field="CustomerID" HeaderText="Customer ID" Width="90"> </ej:Column> <ej:Column Field="EmployeeID" HeaderText="Employee ID" Width="110"></ej:Column> <ej:Column Field="ShipCity" HeaderText="ShipCity" Width="90" /> <ej:Column HeaderText="Order Info" Template="True" TemplateID="#columnTemplate" TextAlign="Center" Width="110" /> </Columns> </ej:grid> <script type="text/x-jsrender" id="columnTemplate"> <asp:Button ID="Button1" runat="server" Text="Info" OnClientClick="myfunction(); return false;"/> </script> <script type="text/javascript"> function myfunction() { $.ajax({ url: "/Default.aspx/Data", type: "POST", dataType: "json", contentType: 'application/json; charset=utf-8', success: function (data) { alert("success")
}, error: function (xhr) { alert('error'); } })
} [System.Web.Services.WebMethod] public static string Data() { //perform operation return data;// return the data |
<script type="text/x-jsrender" id="columnTemplate"> <asp:Button ID="Button1" runat="server" Text="Info" OnClientClick="myfunction(); return false;"/> </script> <script type="text/javascript"> function myfunction() { var gridObj = $("#<%=FlatGrid.ClientID%>").ejGrid("instance"); var customerID = gridObj.getSelectedRecords()[0].CustomerID; $.ajax({ url: "/Default.aspx/Data", type: "POST", contentType: "application/json; charset=utf-8", dataType: "json", data: JSON.stringify({ data: customerID }), success: function (data) { alert(data.d);
}, error: function (xhr) { alert('error'); } }) } [System.Web.Services.WebMethod] public static string Data(string data) { //perform operation return data;// return the data |
<script type="text/x-jsrender" id="columnTemplate"> <asp:Button ID="Button1" runat="server" Text="Info" OnClientClick="myfunction(this); return false;"/> </script> <script type="text/javascript"> function myfunction(element) { var gridObj = $("#<%=FlatGrid.ClientID%>").ejGrid("instance"); var customerID = gridObj.model.currentViewData[gridObj.getIndexByRow($(element).parents("tr"))].CustomerID; $.ajax({ url: "/Default.aspx/Data", type: "POST", contentType: "application/json; charset=utf-8", dataType: "json", data: JSON.stringify({ data: customerID }), success: function (data) { alert(data.d);
}, error: function (xhr) { alert('error'); } })
} |