Hey guys,
i have a dropdown and after select i can edit the selected entry in a form (like http://demos.telerik.com/kendo-ui/mvvm/remote-binding). In the form is another dropdown that depends on another datasource, but the selected value is based on the first on. But if i send a save, then the whole Objekt from the second dropdown is send (something like {ID:"1",text:"abc",check:"true"}) and not the ID only. How can i achieve, that only the ID would be send?
The code vor the observable for the first dropdown which delivers informations for the form:
$(document).ready(function() { var objectViewModel = kendo.observable({ objectSource: new kendo.data.DataSource({ transport: { read: { url: '" . $config['odata_url'] . "Objects?\$filter=ID eq \'" . $_GET["id"] . "\'', dataType: 'json', type: 'GET', contentType: 'application/json', complete: function (jqXhr, textStatus) { if (textStatus == 'success') { $('#windowPopupNotification').data('kendoNotification').show('Data loaded successfully (Object)', 'success'); } else { $('#windowPopupNotification').data('kendoNotification').show('Error while loading data (Object)', 'error'); } } }, update: { url: '" . $config['odata_url'] . "Objects(\'" . $_GET["id"] . "\')?lang=de', dataType: 'json', type: 'MERGE', contentType: 'application/json', complete: function (jqXhr, textStatus) { if (textStatus == 'nocontent') { $('#windowPopupNotification').data('kendoNotification').show('Data saved successfully (Object)', 'success'); } else { $('#windowPopupNotification').data('kendoNotification').show('Error while saving data (Object)', 'error'); } } }, parameterMap: function(options, operation) { if (operation !== 'read' && options) { return kendo.stringify(options); } } }, batch: false, schema: { data: 'd.results', model: { id: 'ID' } } }), selectedObject: null, save: function() { this.objectSource.sync(); }, reset: function() { this.objectSource.read(); }, close: function() { gridItemDetailsWindowClose(); }, showForm: function() { return this.get('selectedObject') !== null; }, }); kendo.bind($('#objectForm'), objectViewModel);});The PHP code for the dropdown in the form.
$DropDown = new \Kendo\UI\DropDownList('DropDownID');$DropDown->autobind(true) ->attr('data-bind', 'value: selectedObject.ID') ->attr('data-value-field', 'ID') ->attr('data-text-field', 'Name') ->dataSource($myDataSource);
Thanks a lot!
Chris