How to trigger editRow() for a specific row in a DataGrid?

Hi, I have a DataGrid InLine edit, and it works correctly.
When I click on the Edit button for a Row, it executes this code:

this.grid0.editRow(${data});

and it puts my row in Edit mode.

All good, now I want to have a button, that executes the same function, editRow(), but I Can pass to it a specific Row to put in Edit mode.

Is this possible? I tried passing to this function the exact copy of the ${data} object of one of my rows, but when I click this button, nothing will happen.

So how can I invoke this.grid0.editRow(${data}); for a Specific row, without clicking the Edit button on that row?

The editRow function expects the data item to be contained in the Data property of the DataGrid. This is why using a copy won't work. Usually the DataGrid is data-bound to a page property (e.g. getProductsResult). To edit say the second item you should use this.grid0.editRow(${getProductsResult[1]})

1 Like

ok thank you for the answer! Is there a way to use editRow() and instead of passing the Array position of the record I want to edit, to pass somehow the PK of that row?

You don't need to pass array position. You need to pass the item of the array at the specified position. You can find it via some code (including by PK):

this.grid0.editRow(${getProductsResult.find(p => p.ProductID == 1)})

2 Likes

great informations, this will come in handy for sure! thank you

@korchev

Hi,

I am trying to implement this: https://blazor.radzen.com/datagrid-inline-edit in my datagrid (based on a REST data source) in my Angular App.

I tried executing this code: this.grid0.editRow(${data});

But nothing seems to happen.
What am i missing out?

Thanks.

You need to define EditTemplate for your DataGrid columns. You can check Radzen DataGrid InLine Edit template for reference:


Thanks @enchev

Could you also point me towards the: Radzen DataGrid InLine Edit template reference?

As, when i try to create a new page with "DataGrid InLine Edit template", i don't see any options for Page Schema.

I was referring more on what's created by the template - you cannot use it for plain REST since it's not following known schema unlike OData for example.

But is it not possible to use the Schemas already defined for the REST data source?

No, since the operation names, parameters, etc. in REST services can vary while in OData you/we know what's the name of the operation to get collection, single object, to update/delete and add entity. OData is standardized REST service with known schema.

As a lot of popular BaaS provide only REST or GraphQL APIs, does this imply that we cannot use them without all such restrictions in the UI/UX ?

There are no restrictions in the UI - you just cannot use the template since we don't know the schema. You can create however quickly what you want using the designer. Again, check the template created for SQL/OData data source to know what you need to create to edit, update, delete and add with your REST service.

Sorry, that's what i meant by restrictions: that most things need to be designed (repeatedly in case of common components, right?) instead of being able to save/reuse them as templates. And also features like sorting/filtering of lookup data.

Yes, there is no support for sorting and filtering in plain REST services. This limitation again is not related to Radzen but comes directly from the service.

Ok.
Also, i assume that the 'restrictions' extend to (REST API based) Authentication/Security features as well?

No, the authentication and security for REST and OData is the same:


We have plans to add ability to mark REST operations during data source definition - what to be used for get, for getBy for update and for add. In this way Radzen CRUD templates will work for REST data sources as well.

The development is still in very early stage however should be available next month.

We have plans to add ability to mark REST operations during data source definition - what to be used for get, for getBy for update and for add. In this way Radzen CRUD templates will work for REST data sources as well.

That sounds great! Thanks for the info.

Also, i guess what i meant was Authorization instead of Authentication.
User management and User/Roles based access within the app.

This is available built-in for SQL data sources only (Microsoft SQL Server, MySQL, PostgreSQL and Oracle).

But still can be implemented for other data sources via some workarounds?