dxDataGrid events e.data object do not returns row key/index info.

Answered
0
0

Hi!

In DXDataGrid I want to be able to:

1 Cancel row deletion

2. Add default value to cells in a newly added row

3. Reject changes in edited row before row being updated.

For some events as selectionChanged, cellClick, keyDown there are a ton of data in e object.

For events like

“rowUpdating”,
“rowUpdated”,
“rowValidating”,
“saved”,
“saving”,
“rowPrepared”,
“rowInserted”,
“rowInserting”,
“rowRemoving”,
“rowRemoved”,

There is nothing for e.data. I in this events need to receive row key/index in order to be able to manipulate row content and reject row editing, row deletion, eventually row adding when it may be necessary.

How to manage that?

In your integration project I added:

case “rowUpdating”:
return {
rowIndex: args.rowIndex,
currentSelectedRowKeys: args.currentSelectedRowKeys,
selectedRowKeys: args.selectedRowKeys
};

case “saving”:
return {
rowIndex: args.rowIndex,
currentSelectedRowKeys: args.currentSelectedRowKeys,
selectedRowKeys: args.selectedRowKeys
};

case “rowRemoving”:
return {
rowIndex: args.rowIndex,
currentSelectedRowKeys: args.currentSelectedRowKeys,
selectedRowKeys: args.selectedRowKeys
};

But  e.data object is still empty.

Thank you!

 

  • You must to post comments
Best Answer
0
0

You can’t process synchronous events on the server and the data object has to be populated in javascript.

You can handle the event on the client easily by adding a WidgetEvent. If you want to wire it back to the server use the promise as shown in the devexpress documentation: https://js.devexpress.com/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/#onRowRemoving

I have attached a sample that shows:

  • Localization (added a static dxBase.Culture since you didn’t want to use the Application.CurrentCulture setting(
  • How to send data back to an initNewRow event (same sync v. async concept as rowDeleting)
  • How to stop deleting a row from the server.

In general, Wisej widgets are all tightly integrated with server functionality. All third party widgets are not designed to interact with the sever and you are supposed to write your code in javascript, or fire off api calls which need an endpoint, a session, etc. With the wisej wrapper most of the work is already there but you still need to wire the api postback if the widget expects a response. Otherwise a normal event works.

Additionally, all third party widgets do not support receiving calls from the server. The wisej wrapper also adds this feature automatically. The other alternative to simply write parts and pieces of your app in javascript, as required by angular and blazor.

 

 

 

  • mgmst
    • mgmst
    • Jun 3, 2021 - 7:07 pm
    Thank you! The tree points features works just fine. Great job. I will study the model for the next features I need.
  • You must to post comments
0
0

Download the latest devextreme extension from Github to use the sample and dxBase.Culture.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.