1

我正在使用淘汰赛剑道,这是我的代码:标记:

<body>
<div id="mursi"
     data-bind="kendoGrid:{ dataSource:{data:selectedAsset().RealEstateAssetBlockParcel ,pageSize:3} ,data:selectedAsset().RealEstateAssetBlockParcel, pageable: true,pageSize:5,sortable:true,scrollable:false,selectable:true,columns:[{title:'parcel'},{title:'plot'},{title:'subplot'},{ width:60},{ width:60}] ,rowTemplate: 'rowParcelTmpl', altRowTemplate: 'altParcelTmpl', useKOTemplates: true }"></div>

<button data-bind="replaceSelectedAsset">click me</button>

<script id="rowParcelTmpl" type="text/html">
    <tr>
        <td>
            <div data-bind="text:Block"></div>
        </td>
        <td>
            <div data-bind="text:Plot"></div>
        </td>
        <td>
            <div data-bind="text:SubPlot"></div>
        </td>
        <td>
            <button class="k-button"><span class="update-button"></span></button>
        </td>
        <td>
            <button class="k-button"><span class="remove-button"></span></button>
        </td>
    </tr>
</script>
<script id="altParcelTmpl" type="text/html">
    <tr class="k-alt">
        <td>
            <div data-bind="text:Block"></div>
        </td>
        <td>
            <div data-bind="text:Plot"></div>
        </td>
        <td>
            <div data-bind="text:SubPlot"></div>
        </td>
        <td>
            <button class="k-button"><span class="update-button"></span></button>
        </td>
        ><span class="remove-button"></span></button></td>
    </tr>
</script>
</body>

这是我的 JS:

var selectedAsset = ko.observable();
//viewmodels
var assetViewModel = function () {
    this.RealEstateAssetBlockParcel = ko.observableArray([]);
};
var asset = new assetViewModel();
asset.RealEstateAssetBlockParcel.push({Block: 1, Plot: 2, SubPlot: 3, Id: 0});
selectedAsset(asset);
var replaceSelectedAsset = function () {
    selectedAsset(asset);
};
ko.applyBindings();

一切都很好,直到您按下“单击我”按钮,该按钮假设选择另一个资产并显示其包裹网格,但我收到以下错误:“未捕获的类型错误:无法调用未定义的“查找”方法”(起源于剑道。网络.all)

http://jsbin.com/oboxig/3/edit 帮助将不胜感激 谢谢

4

1 回答 1

1

我在您的 JSBin 中看到的data-bindbutton.

你能试试:

function replaceSelectedAsset () {
    selectedAsset(asset);
};

并将其定义button为:

<button onclick="replaceSelectedAsset()">click me</button>
于 2013-01-07T12:03:05.750 回答