0
我有下面的代碼,我想向webix數據表添加記錄。我是一個JS新手,所以不確定正確的定義以確保變量作用域是有效的。將按鈕單擊到webix數據表
基本上我有像這樣尋呼機和數據表的正常工作:
webix.ready(function(){
webix.ui({
id: "pagerA",
view: "pager",
template:"{common.prev()} {common.pages()} {common.next()}",
container: "page_section",
size: 15,
group: 5
});
webix.ui({
container:"gasforecast",
rows: [
{type: "header", template: "Gas Forecast"},
gasgrid = {
view:"datatable",
editable: true,
navigation: true,
pager: "pagerA",
columns:[
{ id:"PKey", header:"", hidden:true},
{ id:"SiteName", header:"Site", width:250, sort:"string"},
{ id:"PercentageChange",header:"% Change", width:100, editor: "text", sort:"int"},
{ id:"kWChange", header:"kW Change", width:100, editor: "text", sort:"int"}
],
autoheight:true,
autowidth:true,
select:"row",
save: "data/gasforecastdata_save.php",
url: "data/gasforecastdata.php"
}]});
});
現在我希望能夠有一個按鈕,點擊它時,添加一行到DataTable,所以我補充一下:
cmdAddRow = webix.ui({
container:"addbutton",
view:"button",
label: "Add Site",
click: function() {
var data = {"SiteName": "X", "PercentageChange": 1, "kWChange": 0};
gasgrid.add(data);
}
});
按鈕被點擊然而,當它產生一個「未捕獲的類型錯誤:gasgrid.add不是函數」
我曾嘗試添加一個id:屬性到DataTable和和借鑑e,但我仍然有錯誤。不知道該怎麼辦?
由於
加里