using jQuery to access Grid field values

1 Answer 524 Views
Grid
Jayakumar
Top achievements
Rank 1
Jayakumar asked on 16 Sep 2022, 02:32 PM

What is returned in variable grid in following code line?

var grid = $("#GridCompetency0").data("kendoGrid");

How do I use to access the fields of my Model?

I am using it in the following onChange function.

function onChange(e)
    {
        var grid = $("#GridCompetency0").data("kendoGrid");
        var categoryColumnStatus;
        alert("onChange");
        var request = $.ajax({
            url: '/Base/GetDisplayStatus',
            type: 'POST',
            dataType: 'JSON',
            data: { categoryColumnStatus: false },
            cache: false,
            success: function (data)
            {
                if (data.categoryColumnStatus)
                {
                    grid.showColumn("FunctionalCategoryName");
                }
                else
                {
                    grid.hideColumn("FunctionalCategoryName");
                }
            }
        });

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 21 Sep 2022, 10:30 AM

Hello Jayakumar,

The $("#gridID").data("kendoGrid"); returns the Grid instance. More information you can find in the following article:

In the context of the snippet you have shared it is used to show or hide columns conditionally via the showColumn and hideColumn methods.

In the data source change event, you can access the model with the following properties:

Let me know if you have any questions.

Regards,
Nikolay
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.

Tags
Grid
Asked by
Jayakumar
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or