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

Disable user input on kendo grid

1 Answer 962 Views
Grid
This is a migrated thread and some comments may be shown as answers.
José Angel
Top achievements
Rank 1
José Angel asked on 22 Mar 2016, 09:28 AM

I'm having a few problems while using kendo grid.

I'm trying to add an empty where the user can add rows to it. 
The grid only have 2 rows (ProductCode and ProductQuantity). 

On insert new row, or on editing an existence one, the user should only be able to introduce vales in the ProductCode. The ProductQuantity will be updated using a service.

The following code represents what I've done so far. 

I've added required: false and editable: false  to the ProductQuantity.

I've tried to catch the add event but nothing seems to work.

var dataSource = new kendo.data.DataSource({
    batch: false,
    autoSync: false,
    data: [],
    pageSize: 20,
    schema: {
        model: {
            id: "ProductID",
            fields: {
                ProductCode: { type: "string", validation: { required: true } },
                ProductQuantity: { type: "number", validation: { required: false, editable: false } }
            }
        }
    },
    edit: function (e) {
        if (e.model.isNew() == false) {
            $('[name="ProductQuantity"]').attr("readonly", true);
        }
    },
    change: function (e) {
        if (e.action == "itemchange") {
           //do something
        }
    }
});
 
$("#ap-grid").kendoGrid({
    dataSource: dataSource,
    pageable: false,
    height: 550,
    toolbar: ["create"],
    columns: [
        { field: "ProductCode", title: "Product Code" },
        { field: "ProductQuantity", title: "Quantity" },
                                   { command: ["edit", "destroy"], title: " ", width: "250px" }],
    editable: "inline",
});

How can Iachieve this?

Thanks In advance

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 24 Mar 2016, 08:09 AM
Hi,

The editable option should be set to the field options instead of the validation e.g.
fields: {
    ProductCode: { type: "string", validation: { required: true } },
    ProductQuantity: { type: "number", validation: { required: false }, editable: false }
}


Regards,
Daniel
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
José Angel
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or