Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
147119 | Sep 2,2019 11:00 AM UTC | Sep 3,2019 10:33 AM UTC | React - EJ 2 | 1 |
![]() |
Tags: Grid |
[FetchEmployee.tsx]
public render() {
return (<div className='control-section'>
<GridComponent ref={g => (this as any).grid = g} allowPaging={true} load={this.onload.bind(this)} allowRowDragAndDrop={true} rowDrop={this.dropAction.bind(this)} >
<ColumnsDirective>
<ColumnDirective field='OrderID' headerText='Order ID' isPrimaryKey={true} width='120' textAlign='Right'></ColumnDirective>
<ColumnDirective field='CustomerID' headerText='CustomerID' width='150'></ColumnDirective>
<ColumnDirective field='Freight' headerText='Freight' format="C2" width='120' textAlign='Right' />
<ColumnDirective field='EmployeeID' headerText='Employee ID' type='number' editType='numericedit' width='150'></ColumnDirective>
</ColumnsDirective>
<Inject services={[Edit, Toolbar, RowDD]} />
</GridComponent>
</div>)
public dropAction(args: any) {
args.cancel = true;
var ajax = new Ajax();
ajax.type = "POST"
ajax.url = "/Home/Move"
var moveposition = { oldIndex: args.fromIndex, newIndex: args.dropIndex };
ajax.data = JSON.stringify(moveposition);
ajax.send();
ajax.onSuccess = () => {
(this as any).grid.refresh();
}
} |
[HomeController.cs]
// POST: api/Orders/Move
[HttpPost]
[Route("Move")]
public void Move([FromBody] data data)
{
// you can also change the position of your data based on the from and drop index
var tmp = order[data.oldIndex];
order [data.oldIndex] = order [data.newIndex];
OrdersDetails.GetAllRecords()[data.newIndex] = tmp;
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.