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

Set value of another cell based on selected item from Combo box

1 Answer 341 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 16 May 2013, 06:15 PM
I have a Grid defined as:
$("#FloorPlanGrid").kendoGrid({
        dataSource: floorPlanSource,
        toolbar: ['create'],
        columns: [
            {field: 'CompanyName', title: 'Company Name', editor: flooringDropDown},
            {field: 'AccountNumber', title: 'Account Number'},
            {field: 'CompanySubType', title: 'Sub Type'},
            {field: 'Active', title: 'Active'},
            {field: 'CreditAvailable', title: 'Credit Available'},
            {field: 'DFINumber', title: 'DFI Number'},
            {field: 'ClosedDate', title: 'Closed Date'},
            { command: ['edit', 'destroy'] }
        ],
        editable: 'inline',
        //edit: function (e) {
        //  debugger;
        //}
    });
With a custom editor for the company name defined as:
function flooringDropDown(container, options) {
    $("<input required data-text-field='Text' data-value-field='Value' data-bind='value: " + options.field + "'/>")
        .appendTo(container)
        .kendoDropDownList({
            autoBind: false,
            dataSource: {
                transport: {
                    read: window.PaymentOutsideOptionsUrl
                }
            },
            select: function(e) {
                var item = this.dataItem(e.item.index());
                 
                if (item) {
                    console.log(item.SubType);
                    debugger;
                }
            }
        }
    );
}
Where the debugger line is in the select event, I would like to set the value of the CompanySubType to item.SubType. I have verified that I can get the SubType, but I cannot for the life of me figure out how to set the value of the CompanySubType column. Could someone demonstrate how to set this value?

Jason

1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 18 May 2013, 12:37 PM
Hi Jason,


I would suggest you to get the model for the current item through the options.model parameter and then use it's set method to update the value of CompanySubType.

E.g.
function flooringDropDown(container, options) {
    //get the current model
    var model = options.model;
    $("<input required data-text-field='Text' data-value-field='Value' data-bind='value: " + options.field + "'/>")
            ...
            select: function(e) {
                var item = this.dataItem(e.item.index());
                  
                if (item) {
                    //update the value
                    model.set("CompanySubType", item.SubType);
                }
            }
        }
    );
}

I hope this information was useful for you. 

Kind regards,
Dimiter Madjarov
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Jason
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or