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

Local Datasource: Update does not work

1 Answer 167 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Labhesh
Top achievements
Rank 1
Labhesh asked on 21 Sep 2015, 07:13 PM

Hi, 

I am using treelist under the following scenario:

 

1) i have a local dataset

2) While displaying I use column templating

3) while editing, I create multiple kendo numeric textboxes and appendTo container (code to follow)

4) I am using Angular

 

My problem is that the update method never gets called after i submit and edit to my numeric text box within the treelist cell. I.e after hitting Edit --> Update button, the code in update function (Transport: Update called) never gets invoked...What am I doing wrong?

Also, whats the best way here to update the data and put it back into the grid as well as my datasource?

 

Note to Admins: Since I am using angular, from below code: please give me an angular compatible answer if possible...

 

Thanks a lot, 

Labhesh

------------------------

Here's the code:

 

<div ng-controller="testcontroller as vm">
    <div kendo-treelist="vm.treelist" k-options="vm.tlOptions"></div>
</div>

 

vm.tlOptions = {
    dataSource: {
        transport:{
            read: function(e) {
                console.log("TRANSPORT: READ Called");
                e.success(vm.dataToShow);
            },
            update: function(e){
                console.log("TRANSPORT: UPDATE Called");
                var updatedItems = e.data;
                console.log(updatedItems);
                e.success();
            }
        },
        schema:{
            model: {
                "id": "sId",
                "parentId":"sLink",
                "fields": schemaFlds
            }
        }
    },
    editable:true,
    resizable:true,
    columns: cc
 
};

 

NumericEditor attached to each editable column:

 

var numericEditor = function (container, options) {
 
    $('<input id="abc" style=color:red value='+options.model[options.field].vols.mdl + '"/>')
        .appendTo(container)
        .kendoNumericTextBox({
            decimals: 2,
            format: "n2"
        });
 
    $('<input id="abc" style=color:blue value='+options.model[options.field].vols.usr + '"/>')
        .appendTo(container)
        .kendoNumericTextBox({
            decimals: 2,
            format: "n2"
        });
    $('<label style=color:green>'+options.model[options.field].vols.actual+'</label>')
        .appendTo(container);
 
};

1 Answer, 1 is accepted

Sort by
0
Labhesh
Top achievements
Rank 1
answered on 22 Sep 2015, 01:32 PM

I figured this one out, for anyone curious to know, I was not binding the textbox's value to dataSource. 

It can be done by using data-bind in the <input tag...>

 

var inp = '<input style=color:blue data-bind="value:' + mdl + '"/>';

Tags
Data Source
Asked by
Labhesh
Top achievements
Rank 1
Answers by
Labhesh
Top achievements
Rank 1
Share this question
or