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

Grid inline DropDown with own datasource, but dependent fields?

1 Answer 173 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
martonx
Top achievements
Rank 1
martonx asked on 20 Jun 2012, 10:27 AM
Hi,

I have a Grid with Customer - Order datas. In my datasource model there are customer name and customer id. In the grid there is only the customer name visible.
When I'm editing the row, the Customer name is a DropDownList, with custom Customer datasource (name, id).

So how can I make that, when I change the Customer name in the grid, it sholud change the customer id too in the customerorder datasource? Now my program is working, but when I change Customer with dropdown, in the model its change only the customer name.

I hope I was clear?

I think I should use the DropDownList's change event. How can I get the current datasource item's id field, and update this id to the parent datasource customer id?

function dolgozoDropDownEditor(container, options) {
    $('<input data-text-field="nev" data-value-field="nev" data-bind="value:' + options.field + '"/>')
        .appendTo(container)
        .kendoDropDownList({
            autoBind: false,
            dataSource: dolgozodata,
            change: function () {
                options.model.dszam = 100; // Here I need this.dataitem.id or something like this
            }
        });
}


Please advice,
Lajos

1 Answer, 1 is accepted

Sort by
0
martonx
Top achievements
Rank 1
answered on 20 Jun 2012, 01:07 PM
I solved:

function dolgozoDropDownEditor(container, options) {
    $('<input data-text-field="nev" data-value-field="nev" data-bind="value:' + options.field + '"/>')
        .appendTo(container)
        .kendoDropDownList({
            autoBind: false,
            dataSource: dolgozodata,
            change: function () {
                dataItem = this.dataItem(this.selectedIndex);
                options.model.customerid = dataItem.id;
            }
        });
}
Tags
Data Source
Asked by
martonx
Top achievements
Rank 1
Answers by
martonx
Top achievements
Rank 1
Share this question
or