Page 1 of 1

[Answered] Insert row above an existing specified row

Posted: Tue Dec 29, 2020 8:20 am
by gregc

Do you have any code snippets for inserting a row some place in the grid from a right click, like in Excel ?
I guess its a store add above a certain record by id, something like that?


Re: Insert row above an existing specified row

Posted: Tue Dec 29, 2020 11:42 am
by mats

Re: Insert row above an existing specified row [Answered]

Posted: Sat Jan 02, 2021 3:46 am
by gregc

Took me a while to get to the point of implementing this, In this case I was able to get the existing record, get the display sequence that I use in the grid, insert a new record, which triggers the AJAX call and returns a saved database record

function insertrow(params) {
	// row index in table
	var rowindex = params.cellData.row._index;
	// record clicked on 
	var existingrecord = params.record;
	// get the store and call 
	params.source._store.insert(rowindex, {fieldname:'New Field', displayseq: existingrecord.displayseq});
}

I really like working with this grid, it feels very powerful, thanks !