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

Editing only certain cells/columns

2 Answers 1237 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Luk
Top achievements
Rank 1
Luk asked on 16 Jan 2012, 01:59 PM
Hi,

I would like to make my Kendo Grid editable only for a certain cells (depends on a value in them) or only a certain columns (i.e. only the second column in grid). How can I achieve this goal?

2 Answers, 1 is accepted

Sort by
0
Luk
Top achievements
Rank 1
answered on 17 Jan 2012, 10:11 AM
Ok, I partialy resolved the second problem. Disabling editing on a certain column is as simple as define it impossible in data schema, as stated in documentation:

var dataSource = new kendo.data.DataSource({
//..
schema: {
      model: {
         id: "ProductID",
         fields: {
             ProductID: {
                //this field will not be editable (default value is true)
                editable: false,
                // a defaultValue will not be assigned (default value is false)
                nullable: true
             },
             ProductName: {
                validation: { //set validation rules
                    required: true
                }
             },
             UnitPrice: {
                 //data type of the field {Number|String|Boolean} default is String
                 type: "number",
                 // used when new model is created
                 defaultValue: 42,
                 validation: {
                    required: true,
                    min: 1
                 }
              }
           }
       }
  }
});


Like I said, this is a partial solution, due to the fact, that I can specify some additional columns in grid, that are not fetched from DataSource, but are added for example from template:

columns: [
            {
                field: "id",
                title: "ID"
            },
            {
                field: "firstName",
                title: "First Name"
            },
            {
                field: "lastName",
                title: "Last Name"
            },
            {
                title: "Actions",
                template: '<a href="javascript:vm.editUser(#= id #)">Edit</a> <a href="javascript:vm.removeUser(#= id #)">Delete</a>'
            }
        ]


In the latter case, there is no schema in which I could define, that column entitled "Actions" should not be editable.
 
The first issue is still a question mark...
0
Mat
Top achievements
Rank 1
answered on 30 Apr 2012, 10:23 AM
I'd really like to achieve something similar to this. I need an editable grid, which has certain fields that are not from the data source. 

Basically, I retrieve a list of employees from the remote data source and display them in a grid, but I need to be able to save additional data associated with each employee into a different table.

I can achieve this using a row template and lots of input fields, but I'd rather use the grid's built in editable features as they are a much better user experience.

Is there any way to do this? If so, is there aslo a way to make one of the additional 'pseudo' columns into a drop-down list?

Any pointers would be much appreciated.

Thanks.
Tags
Grid
Asked by
Luk
Top achievements
Rank 1
Answers by
Luk
Top achievements
Rank 1
Mat
Top achievements
Rank 1
Share this question
or