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

I want to disable 2nd column when 1 st row is inserted in a kendo grid, not after that

2 Answers 36 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Anand Vardhan
Top achievements
Rank 1
Anand Vardhan asked on 05 Oct 2016, 09:07 AM
I have a kendo ui grid with custom button which adds a new row.
In that, I want to disable 2nd column when 1st row is inserted.
From 2nd row on wards, I want that column to be enabled.
I Also want to insert count in 1st column on every insert in the grid.
For example: If the first row is inserted, I want 1st column to be "Tier 1".
If 2nd row is inserted, then I want 1st column of 2nd row to be as "Tier 2".
If out of 3, 2nd row is deleted... I want the 3rd row 1st column to be converted from "Tier 3" to "Tier 2".
Can someone please help me achieve this?
I am struggling to have this much of control in kendo grid.

2 Answers, 1 is accepted

Sort by
0
Marc
Top achievements
Rank 1
answered on 05 Oct 2016, 04:58 PM

Something like this will disable certain fields dynamically when adding or editing (change the if statement to true/false accordingly)

    function onEdit(e) {
        if (e.model.isNew() === false) {
            $("#PartNum").addClass("form-control");
            $("#PartNum").attr('disabled', 'disabled');
        }
    }

 

From there I think you may be able to set properties of your item which is being passed in as (e.model).

0
Alexander Popov
Telerik team
answered on 07 Oct 2016, 07:57 AM
Hello Anand,

My advice is to use the Grid's API and more specifically - the setOptions and addRow methods (in that order). This will allow you to modify the columns configuration before adding the new row. You can also get the total amount of items from the Grid's DataSource API, thus determining what the column titles should be.

Regards,
Alexander Popov
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
Tags
Grid
Asked by
Anand Vardhan
Top achievements
Rank 1
Answers by
Marc
Top achievements
Rank 1
Alexander Popov
Telerik team
Share this question
or