<ej:button id="Button1" runat="server" type="Button" clientsideonclick="btnClick" text="Add Record"></ej:button> <ej:grid id="FlatGrid" runat="server" allowscrolling="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" /> </Columns> <EditSettings AllowEditing="True" AllowAdding="True" AllowDeleting="True" RowPosition="Bottom"></EditSettings> <ClientSideEvents ActionBegin="beginCuentas" QueryCellInfo="cellEventCuentas" CellSave="cellSaveCuentas" CellEdit="cellEditCuentas" ActionComplete="actionComplete" /> <ToolbarSettings ShowToolbar="True" ToolbarItems="add,edit,delete,update,cancel"></ToolbarSettings> </ej:grid> <script type="text/javascript"> function btnClick(e) { var gridObject = $('#<%= FlatGrid.ClientID %>').data("ejGrid"); gridObject.addRecord({ "OrderID": 10011, "CustomerID": "VINNET", "EmployeeID": 5, "ShipCity": "Itally"}); } function actionComplete(args) { if (args.requestType == "save") { this.model.dataSource.shift();// Remove the newly added record from first position this.model.dataSource.push(args.data)// Push the newly added record in data source this.refreshContent(); } } |
function actionComplete(args) { if (args.requestType == "save") { this.model.dataSource.shift();// Remove the newly added record from first position this.model.dataSource.push(args.data)// Push the newly added record in data source this.refreshContent(); var scrollObj = this.getScrollObject(); scrollObj.model.scrollTop = scrollObj.model.height;// Scroll at end of the grid scrollObj.refresh(); this.selectRows($.inArray(args.data, this.model.dataSource))// Perform selection dynamically } |
Hi Jorge,
We are happy that the provided suggestion helped you.
Please get back to us if you need any further assistance.
Regards,
Sellappandi R