MVVM grid - schema.model in dataSource breaks update

1 Answer 36 Views
Top achievements
Rank 1
Robin asked on 23 Jul 2021, 08:41 AM


First of all, this one is build up on an earlier issue :

Dojo for the current issue is:

Issue with this one are lines 161-166.
I want to set the field types, to get the correct column filters, date filter with lte, gt, .. im this example.

Where the fields aren't the special issue here, it's the schema.model object they are in.
As soon as I set the "model", example breaks.

To test it, try dojo as it is and click the "Update date" button.
Nothing will happen.
As soon as you remove lines 161-166 (the model), everything is fine and clicking the button will update the cell in the grid.

I don't know the issue's coming from the special "update single cell value" or from somewhere else, I just cannot say why an empty model object in schema will break the update functionallity.

So hope you can bring a bit of light in the dark.

Greets Robin

1 Answer, 1 is accepted

Sort by
Georgi Denchev
Telerik team
answered on 28 Jul 2021, 08:28 AM

Hello, Robin,

Thank you for the provided dojo.

When the schema.model is not configured, the DataSource will initialize the data using a default model, which in your case is the observable object.

Here's an example of the _data array when the schema.model is missing:

When you add the configuration, the dataSource is going to generate a Model using the provided data, however this model will not be the observable that you are attempting to update. You can verify that by examining the _data collection when schema.model is set:

In this case you would have to call the read() method of the dataSource in order to re-fetch the updated data in the array or you will have to skip defining the schema.model.

Let me know if you have any questions.

Best Regards,
Georgi Denchev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Top achievements
Rank 1
commented on 05 Aug 2021, 11:59 AM

Hi Georgi

Skipping the definition is only an option, if column filters can be defined in another way.
But so far the only way I (may) found, is to build all the filter logic on my own, which is not a good option.

As from my dojo, is there a way to alter it, while maintaining the array as the plain data and the single cell update, so I don't need to alter my source and don't reloading the whole grid on every update.

Greets Robin

Georgi Denchev
Telerik team
commented on 10 Aug 2021, 09:26 AM

Hi, Robin,

The closest thing to a single cell update that you can do, is what my colleague has suggested in the previous thread.

Detaching the change event, updating the dataItem and rendered result manually and then reattaching the change event. The Grid is not designed to work in the required manner and as you have already observed, certain custom solutions may solve one problem, but it leads to others. In this case it is the schema and the filtering.

You can change the kendoFilterMenu of the Date column to type 'date' manually, this will render the datepickers:

$($("th")[1]).data("kendoFilterMenu").type = "date";

However this still wouldn't solve the problem because the value will arrive as a string in the Grid's datasource, instead of a date object.

Unfortunately, building the filter logic manually is the only way to go, if you wish to use the approach from the Dojo.

Asked by
Top achievements
Rank 1
Answers by
Georgi Denchev
Telerik team
Share this question