<div>
<ej:Button ID="Button" runat="server" Size="Normal" Type="Reset" ClientSideOnClick="btnClick" ShowRoundedCorner="true" Text="Add"></ej:Button>
</div>
<div>
<ej:Grid ID="OrdersGrid" runat="server" AllowPaging="True">
<ToolbarSettings ShowToolbar="True" ToolbarItems="edit,delete,update,cancel"></ToolbarSettings>
<EditSettings AllowEditing="true" AllowAdding="true" AllowDeleting="true"></EditSettings>
<Columns>
………………
</Columns>
</ej:Grid>
</div>
<script>
function btnClick(args) {
$.ajax({
type: "POST",
url: "Default.aspx/AddAction",
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (data) {
var gridObj = $("#OrdersGrid").ejGrid("instance"); // get grid instance using grid ID.
gridObj.addRecord({ "OrderID": data.d[0].OrderID, "CustomerID": data.d[0].CustomerID, "EmployeeID": data.d[0].EmployeeID });
},
error: function (args) {
}
});
}
</script>
Server End method
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static object AddAction()
{
// do your stuff here.
}
|