0

我有一个带有自定义编辑模板的剑道列表视图,

这是列表视图代码

var warrantyContact_listview = $("#warrantyContact_listview").kendoListView({
        autoBind: false,
        dataSource: dataSource,
        template: kendo.template($("#warrantyContact_listview_template").html()),
        editTemplate: kendo.template($("#warrantyContact_editview_template").html())
    }).data("kendoListView");

这是编辑模板代码

<script type="text/x-kendo-tmpl" id="warrantyContact_editview_template">
    <div id="con_editview">        
    <dd>
    <dt>Person</dt>
    <input type="text" 
    data-role = "autocomplete" 
    data-source = "some_datasource" 
    data-text-field = "fname"  
    data-value-field = "bid"
    class="k-textbox" 
    data-bind="value:some_value" 
    name="builder" 
    required = "required"
    validationMessage = "required"  
    id="builder"/>
    <span data-for="some_value" class="k-invalid-msg"></span>
    </dd><br clear="all"/>                       

    <dt>City</dt>
    <dd>
    <input type="text" class="k-textbox" data-bind="value:city" name="city" required = "required" validationMessage = "required" />
    <span data-for="city" class="k-invalid-msg"></span>
    </dd><br clear="all"/>

    <dt>State</dt>
    <dd>
    <input type="text" name = "state" class="k-textbox"  data-bind = "value:state" data-value-field="abbrev" data-text-field="abbrev" data-min-length="1" data-source="states_datasource" data-role="autocomplete" required = "required" validationMessage = "required" />
    <span data-for="state" class="k-invalid-msg"></span>
    </dd><br clear="all"/>

    <dt>Zip</dt>
    <dd>
    <input type="text" class="k-textbox" data-bind="value:zip" name="zip" required = "required" validationMessage = "required" />
    <span data-for="zip" class="k-invalid-msg"></span>
    </dd><br clear="all"/>

    </dl>
    </div>
</script>  

这是场景

当列表视图进入编辑模式时,我将填写第一个字段“人员”,这是一个自动完成的字段。

根据我为自动完成“人员”选择的值,我想将其对应的值分配给城市、州和邮政编码。我能够成功分配值。(我在 Person Auto 的 select 事件中使用 jquery ajax 完成)

但是,当我打电话给$("#warrantyContact_listview").data("kendoListView").save();

当我检查萤火虫控制台时,

那些更改的值 city、state 和 zip 不会传递到服务器端。

我在这里缺少什么?

我是否必须在此处更改模板中的值绑定?

我试图更改参数映射函数中的值,但是它不起作用。

任何帮助将不胜感激!

4

1 回答 1

1

My first guess is that when you change the values, you don't use the set() method of the ObservableObject in dataSource, so the kendo dataSource doesn't know that the fields of the observable are modified. So on save() ( which calls sync() for the dataSource ) it doesn't see anything new, and it doesn't update anything.

Check manually your datasource, change something with set() and use save() to see if it's saved.

于 2013-06-27T11:30:40.267 回答