您好请帮助将数据加载到掌上电脑的电子表格 我想添加这样的内容,在列中添加“#bad Value#”。
$("#benefitDT").handsontable({
data: benefitData(),
// colWidths: [55, 127, 127, 147, 157, 147, 147, 147],
rowHeaders: true,
colHeaders: true,
colHeaders: ["Name", "Yes/No", "Add/Nil", "Nil/Multiple", "Field Name", "Value", "Information"],
stretchH: 'all',
startRows: 5,
fillHandle: true,
columns: [
{
readOnly:true
},
{
type: 'checkbox',
checkedTemplate: 'yes',
uncheckedTemplate: 'no'
// source: ["Nil", "Add"]
},
{
type: 'dropdown',
source: ["Nil", "Add"]
},
{
type: 'dropdown',
source: ["Nil", "Multiple"]
},
{
type: 'dropdown',
source: ["Select", "No of Passenger", "No Of Cylinders", "No Of Doors"]
},
{
type: 'numeric',
format: '$ 0,0[.]00',
language: 'en' //this is the default locale, set up for USD
},
{
}
],
minSpareRows: 1
});
我正在尝试从Web服务获取数据并进行创建 一个数组对象并返回相同的
function benefitData() {
var obj = new Array();
var ncbData = [];
XXXXXXXX_apps.GetBenefits(function (arg) {
if (arg.length > 0) {
for (var i=1; i < arg.length - 1; i++) {
var temp = [arg[i].split("|")[2], "yes", "Nil", "Nil", "Select", 12, 13];
}
}
}
return obj;
}
答案 0 :(得分:0)
以json格式获取数据
Public Function GetRates(ByVal ratesheetID As String) As String
Dim alObj As New ArrayList()
Dim dt As DataSet = xxxxxxxxx.GetAllRates(ratesheetID)
Dim ratelist As New List(Of Rates)
For Each dr As DataRow In dt.Tables(0).Rows
Dim rate As New Rates()
rate.YEAR = dr("YEAR")
rate.AGENCYRATE = dr("AGENCYRATE")
rate.AGENCYLOADING = dr("AGENCYLOADING")
rate.AGENCYMINIPREMIUM = dr("AGENCYMINIPREMIUM")
rate.NONAGENCYRATE = dr("NONAGENCYRATE")
rate.NONAGENCYLOADING = dr("NONAGENCYLOADING")
rate.NONAGENCYMINPREMIUM = dr("NONAGENCYMINPREMIUM")
rate.EXCESS = dr("EXCESS")
ratelist.Add(rate)
Next
Dim jss As New JavaScriptSerializer()
Dim _JsonString = jss.Serialize(ratelist)
Return _JsonString
End Function
在加载时使用jquery页面将数据转换为json格式 根据电子表格中的数据类型和控件设置列样式。 根据您的数据设置电子表格设置后加载数据。
function GenerateRateSheet() {
var obj = new Array();
var ncbData = [];
loading("start");
xxxxxxxxxxxxxx.GetRates($("#hdRID").val(), function (obj1) {
debugger;
var arg = $.parseJSON(obj1);
if (arg.length > 0) {
debugger;
$("#rateDT").handsontable({
// data: obj,
colHeaders: true,
colHeaders: ["YEAR", "Agency Rate (%)", "Agency Loading", "Agency MP", "Non Agency Rate (%)", "Non Agency Loading", "Non Agency MP", "Excess/Deductible"],
currentRowClassName: 'currentRow',
currentColClassName: 'currentCol',
colWidths: [100, 150, 110, 100, 175, 160, 130, 180],
startRows: 6,
startCols: 8,
contextMenu: { items: { 'row_above': {}, 'row_below': {}, 'remove_row': {}, 'undo': {}, 'redo': {}} },
columnSorting: {
column: 1,
sortOrder: true
},
persistentState: true,
columns: [
{
data: "YEAR",
allowInvalid: false,
type: 'numeric'
//readOnly: true
},
{ data: "AGENCYRATE",
type: 'numeric',
format: '0.00%',
allowInvalid: false,
language: 'en' //this is the default locale, set up for USD
}
,
{ data: "AGENCYLOADING",
type: 'numeric',
format: '0,0[.]00',
allowInvalid: false,
language: 'en' //i18n: use this for EUR (German)
//more locales available on numeraljs.com
},
{ data: "AGENCYMINIPREMIUM",
// data: "Agency MP",
type: 'numeric',
format: '0,0[.]00',
allowInvalid: false,
language: 'en' //this is the default locale, set up for USD
},
{ data: "NONAGENCYRATE",
// data: "Non Agency Rate (%)",
type: 'numeric',
format: '0.00%',
allowInvalid: false,
language: 'en' //i18n: use this for EUR (German)
//more locales available on numeraljs.com
},
{ data: "NONAGENCYLOADING",
// data: "Non Agency Loading",
type: 'numeric',
format: '0,0[.]00',
allowInvalid: false,
language: 'en' //this is the default locale, set up for USD
},
{ data: "NONAGENCYMINPREMIUM",
// data: "Non Agency MP",
type: 'numeric',
format: '0,0[.]00',
allowInvalid: false,
language: 'en' //i18n: use this for EUR (German)
//more locales available on numeraljs.com
},
{
data: "EXCESS",
type: 'numeric',
format: '0,0[.]00',
allowInvalid: false,
language: 'en' //this is the default locale, set up for USD
}
]
});
$("#rateDT").handsontable("loadData", arg);
loading("end");
}
},
function (arg) {
$("#divResult").html('<div class="alert"><button class="close" data-dismiss="alert">×</button><strong>Warning!</strong> Internal Server Error.</div>');
});
}
//希望它会有所帮助,如果没有那么试着打破解决方案我的小块然后尝试。因为我没有时间把所有事情都推迟。