This is a migrated thread and some comments may be shown as answers.

Conditional set Grid column Editable

7 Answers 2776 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Daochuen
Top achievements
Rank 1
Iron
Veteran
Iron
Daochuen asked on 19 Sep 2020, 06:46 AM

Hello,

I tried to conditional set Grid column Editable status at run time as below code but caused page error. Could anyone give me advice how to do it?  Thanks in advance.

 

      .Model(model =>

              {

                  model.Id(p => p.Id);

                  model.Field(p => p.JobTitle).Editable("isEditable");  <---

                  model.Field(p => p.FirstName).Editable(true);

                  model.Field(p => p.LastName).Editable(true);

              })

 

<script>

    function isEditable(dataItem) {

        return dataItem.Id !=3;

    }

</script>

7 Answers, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 22 Sep 2020, 12:34 PM

Hello,

To determine whether a column is editable run time, you have to use the column.Editable setting, not the model.field.Editable configuration.

e.g.

columns.Bound(p => p.JobTitle).Editable("isEditable")

 

Regards,
Georgi
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

0
Daochuen
Top achievements
Rank 1
Iron
Veteran
Iron
answered on 22 Sep 2020, 01:50 PM

Thanks for your responding Georgi. If I add code as below my application throw the error.

columns.Bound(p => p.JobTitle).Editable("isEditable")

 

Error:

'Kendo.Mvc.UI.Fluent.GridBoundColumnBuilder<XXXXXX>' does not contain a definition for 'Editable' and no extension method 'Editable' accepting a first argument of type 'Kendo.Mvc.UI.Fluent.GridBoundColumnBuilder<XXXXX>' could be found .....

0
Georgi
Telerik team
answered on 24 Sep 2020, 10:16 AM

Hi,

Looking at the error message the type of the passed parameter to the Editable method is incorrect. The error message states that the type of the passed parameter is 'Kendo.Mvc.UI.Fluent.GridBoundColumnBuilder<XXXXX>', however, it should be a string.

Would it be possible to share the full configuration of your grid with us?

Regards,
Georgi
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

0
Daochuen
Top achievements
Rank 1
Iron
Veteran
Iron
answered on 25 Sep 2020, 02:23 AM

Hi Georgi,

As I said before when I used column.Editable setting, I got following error:

error CS1061: 'Kendo.Mvc.UI.Fluent.GridBoundColumnBuilder< ManageTeam.Areas.Models.TeamMember>' does not contain a definition for 'Editable' and no extension method 'Editable' accepting a first argument of type 'Kendo.Mvc.UI.Fluent.GridBoundColumnBuilder< ManageTeam.Areas.Models.TeamMember>' could be found (are you missing a using directive or an assembly reference?)Source: System.WebStackTrace:    at System.Web.Compilation.AssemblyBuilder.Compile()   at ...

I attached Index file and related images inside zip file.

Thanks for your support.

0
Accepted
Tsvetomir
Telerik team
answered on 28 Sep 2020, 01:07 PM

Hi Daochuen,

I have investigated the provided code snippet and the declaration seems correct. However, I have noticed that the referenced version for this thread is 2020.3.915, can you confirm that you are using the latest version of the suite? I am asking due to the fact that the Editable option might be missing in certain older versions. 

Make sure that the Kendo.Mvc.dll is using the latest version as well as the referenced client-side resources use the latest version.

 

Regards,
Tsvetomir
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

0
Daochuen
Top achievements
Rank 1
Iron
Veteran
Iron
answered on 28 Sep 2020, 02:01 PM
We did not used latest version. May that caused Enabled function not work on kendo grid column setting. Thanks.
0
Tsvetomir
Telerik team
answered on 30 Sep 2020, 09:37 AM

Hi,

The issue with the Editable option is related to the version of the product that is used. Since the product is in active development with every release there are new features, enhancements, bug fixes, and new components. Therefore, there are versions under which specific features are not available. 

It is recommended to always keep up-to-date with the latest versions of the suite.

 

Kind regards,
Tsvetomir
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Daochuen
Top achievements
Rank 1
Iron
Veteran
Iron
Answers by
Georgi
Telerik team
Daochuen
Top achievements
Rank 1
Iron
Veteran
Iron
Tsvetomir
Telerik team
Share this question
or