|
var gridInstance = document.getElementById('Grid').ej2_instances[0];
var newData = { 'OrderID': 112, 'Name': 'John', 'Year': 2018 }
gridInstance.addRecord(newData); |
|
// Grid’s actionBegin event function
function actionBegin(args) {
if (args.requestType === 'save' && this.editSettings.newRowPosition === 'Bottom') {
// Newly added row’s index position is changed to last index
args.index = (this.pageSettings.currentPage * this.pageSettings.pageSize) - 1;
}
} |
Hi Paul,
Greetings from Syncfusion support.Query – 1: “It always seems to add the data to the top of the grid, even though i have on the grid settings for new records to be at the bottom of the grid”
For adding new records we suggest you to use the Grid’s addRecord method as demonstrated in the below code snippet,
var gridInstance = document.getElementById('Grid').ej2_instances[0];var newData = { 'OrderID': 112, 'Name': 'John', 'Year': 2018 }gridInstance.addRecord(newData);And for adding records to the bottom of the Grid - If the newRowPosition in the editSettings is set to ‘Bottom’ then the new row will be displayed at the bottom. But after updating the record it will be moved to the top so that the new record will be in display position which is the default behavior. However you can maintain the row position in the bottom itself by changing its index position in the Grid’s actionBegin event. This is demonstrated in the below code snippet,
// Grid’s actionBegin event functionfunction actionBegin(args) {if (args.requestType === 'save' && this.editSettings.newRowPosition === 'Bottom') {// Newly added row’s index position is changed to last indexargs.index = (this.pageSettings.currentPage * this.pageSettings.pageSize) - 1;}}
We have prepared a sample based on this for your reference. You can download it from the following link,
Query – 2: “How are you able to add html elements to the datetime picker such as required as i cannot seem to find anywhere how to add html elements to controls like the date time picker”Please update below details to proceed further with this query,1. Share your exact scenario to add the additional html element into datetimepicker component.2. Explain in which area you want to add the html element like any icons or buttons into the popup element or input element.These details will help us identify your exact requirement so that we can provide the proper solution as earlier as possible.
Let us know if you have any concerns.Regards,Sujith R
|
var newRowAdded = false;
function actionBegin(args) {
if (args.requestType === 'save' && this.editSettings.newRowPosition === 'Bottom') {
// Newly added row’s index position is changed to last index
args.index = (this.pageSettings.currentPage * this.pageSettings.pageSize) - 1;
// Global variable to check this case in the rowSelecting event
newRowAdded = true;
}
}
// Grid’s rowSelecting event handler
function OnRowSelecting(args) {
if (newRowAdded) {
newRowAdded = false;
// Selection is cancelled if it is new row added case(using global variable)
args.cancel = true;
// Last row index is selected(Newly added row)
this.selectRow(this.pageSettings.pageSize - 1);
}
} |