|
export class DragWithGrid extends SampleBase{
rowDrop(args) {
var grid = document.getElementByID('DestGrid').ej2_instances[0];
args.cancel = true;
let ajax = new ej.base.Ajax();
ajax.type = "POST"
ajax.url = "Home/Move"
let moveposition = { oldIndex: args.fromIndex, data: args.data, newIndex: args.dropIndex };
ajax.data = JSON.stringify(moveposition);
ajax.send();
ajax.onSuccess = () => {
grid.refresh(); // refresh the Grid
}
}
render() {
return (
<div className="control-pane">
<div className="control-section">
<GridComponent
dataSource={orderDetails}
rowDrop={this.rowDrop.bind(this)}
allowRowDragAndDrop={true}
height="400"
selectionSettings={{ type: "Multiple" }}
>
<ColumnsDirective>
. . . .
</ColumnsDirective>
<Inject services={[RowDD, Selection]} />
</GridComponent>
} |
|
public void move([FromBody]values data)
{
// you can also change the position of your data based on the from and drop index
var tmp = OrdersDetails.GetAllRecords()[data.oldIndex];
OrdersDetails.GetAllRecords()[data.oldIndex] = OrdersDetails.GetAllRecords()[data.newIndex];
OrdersDetails.GetAllRecords()[data.newIndex] = tmp;
} |