<ej:Grid ID="EmployeesGrid" runat="server" MinHeigh="600" MinWidth="500" AllowPaging="true" >
<EditSettings AllowEditing="True" AllowAdding="True" AllowDeleting="True"></EditSettings>
<ToolbarSettings ShowToolbar="true" ToolbarItems="add,edit,delete,update,cancel,search"></ToolbarSettings>
<ClientSideEvents Create="create" />
<Columns>
----
</Columns>
</ej:Grid>
<ej:Button ID="ButtonNormal" runat="server" Type="Button" Text="Save" Size="Normal" ShowRoundedCorner="true" ContentType="TextOnly" PrefixIcon="e-icon e-uiLight e-handup" ClientSideOnClick="btnClick" ></ej:Button>
<script>
function btnClick(args) {
var gridObj = $("#MainContent_EmployeesGrid").ejGrid("instance");
gridObj.addRecord({ "EmployeeID": 1000, "FirstName": $("#text1").val(), "LastName": $("#text2").val(), "Title": $("#text3").val() });
}
function create(args) {
var newTr = '<tr class="e-row" data-role="row"><td class="e-rowcell" data-role="gridcell" ><input id="text1" type="text"></td><td class="e-rowcell" data-role="gridcell"> <input id="text2" type="text"></td><td class="e-rowcell" data-role="gridcell"><input id="text3" type="text"></td></tr>';
this.getContentTable().append(newTr);
$('#text1').ejAutocomplete({
dataSource: window.gridData,
fields: { key: "OrderID", text: "CustomerID" },
});
$('#text2').ejAutocomplete({
dataSource: window.gridData,
fields: { key: "OrderID", text: "ShipCity" },
});
$('#text3').ejAutocomplete({
dataSource: window.gridData,
fields: { key: "OrderID", text: "ShipCountry" },
});
}
</script> |
<ej:Grid ID="OrdersGrid" runat="server" AllowPaging="True" >
<ClientSideEvents RecordClick="recordClick" />
<EditSettings AllowEditOnDblClick="false" AllowEditing="True" AllowAdding="true" AllowDeleting="True"></EditSettings>
<ToolbarSettings ShowToolbar="True" ToolbarItems="add,edit,delete,update,cancel"></ToolbarSettings>
<Columns>
-----
</Columns>
</ej:Grid>
<script type="text/javascript">
function recordClick(args) {
if (this.model.editSettings.editMode == "normal") {
this.startEdit(args.row); //trigger to edit the row
}
} </script> |
function actionBegin(args) {
if (args.requestType == "save") {
var data = args.data;
}
}
|