【15.1.1】能否在加载ssjson后将table里的某一列设置为combobox格式
RT 暂时还没有计划,你这个可以作为需求记录,帖子我先移动到需求板块去 可以用增量加载,在loaded的回调中找到对应table所需设置的区域,然后通过下面的代码设置combocox。var combo = new GC.Spread.Sheets.CellTypes.ComboBox();sheet.setCellType(3, 2, combo, GC.Spread.Sheets.SheetArea.viewport);
这是增量加载的地址
https://demo.grapecity.com.cn/spreadjs/SpreadJSTutorial/features/workbook/incremental-loading#timestamp
var combo = new spreadNS.CellTypes.ComboBox();
combo
.items([
{ text: "Oranges", value: "11k" },
{ text: "Apples", value: "15k" },
{ text: "Grape", value: "100k" },
])
.editorValueType(spreadNS.CellTypes.EditorValueType.text);
var tableColumn5 = new spreadNS.Tables.TableColumn(
5,
"isDelivered",
"Delivered",
null,
combo
);
table.autoGenerateColumns(false);
table.bind(
[
tableColumn1,
tableColumn2,
tableColumn3,
tableColumn4,
tableColumn5,
],
"sales",
data
);
新建表格的时候给列设置格式,我在官网看到过例子。
现在问题是加载ssjson以后,我好像没法通过api改变表格某一列的格式。:dizzy: 本帖最后由 Richard.Ma 于 2022-11-7 14:33 编辑
我看到你上面的代码中还有做数据绑定,可以发一个重现问题的demo上来,我帮你看一下原因 Richard.Ma 发表于 2022-11-7 14:31
我看到你上面的代码中还有做数据绑定,可以发一个重现问题的demo上来,我帮你看一下原因
{
"version": "15.1.1",
"sheetCount": 1,
"customList": [],
"sheets": {
"Sheet1": {
"name": "Sheet1",
"isSelected": true,
"activeRow": 5,
"activeCol": 7,
"visible": 1,
"frozenTrailingRowStickToEdge": true,
"frozenTrailingColumnStickToEdge": true,
"theme": "Office",
"data": {
"dataTable": { "5": { "1": { "value": "合计:" } } },
"defaultDataNode": { "style": { "themeFont": "Body" } }
},
"rowHeaderData": {
"defaultDataNode": { "style": { "themeFont": "Body" } }
},
"colHeaderData": {
"defaultDataNode": { "style": { "themeFont": "Body" } }
},
"leftCellIndex": 0,
"topCellIndex": 0,
"selections": {
"0": { "row": 5, "rowCount": 1, "col": 7, "colCount": 1 },
"length": 1
},
"rowOutlines": { "items": [] },
"columnOutlines": { "items": [] },
"cellStates": {},
"states": {},
"outlineColumnOptions": {},
"autoMergeRangeInfos": [],
"tables": [
{
"name": "Tab_1",
"row": 1,
"col": 1,
"rowCount": 5,
"colCount": 6,
"showFooter": true,
"expandBoundRows": true,
"style": {
"wholeTableStyle": {
"backColor": "white",
"foreColor": "black",
"font": "10pt arial",
"borderLeft": { "style": 1 },
"borderTop": { "style": 1 },
"borderRight": { "style": 1 },
"borderBottom": { "style": 1 },
"borderHorizontal": { "style": 1 },
"borderVertical": { "style": 1 }
}
},
"autoGenerateColumns": false,
"bindingPath": "table1",
"rowFilter": {
"range": { "row": 2, "rowCount": 3, "col": 1, "colCount": 6 },
"typeName": "HideRowFilter",
"dialogVisibleInfo": {},
"filterButtonVisibleInfo": {
"0": true,
"1": true,
"2": true,
"3": true,
"4": true,
"5": true
},
"showFilterButton": true,
"filteredOutRows": [],
"tableName": "Tab_1"
},
"columns": [
{
"id": 1,
"name": "列1",
"dataField": "col1",
"footerValue": "合计:"
},
{ "id": 2, "name": "列2", "dataField": "col2" },
{ "id": 3, "name": "列3", "dataField": "col3" },
{ "id": 4, "name": "列4", "dataField": "col4" },
{ "id": 5, "name": "列5", "dataField": "col5" },
{ "id": 6, "name": "列6", "dataField": "col6" }
]
}
],
"index": 0
}
},
"sheetTabCount": 0
}
比如我生成了如上的ssjson,我想在加载这个ssjson后,用代码将‘列1’变为combobox,该如何实现呢? 如果是要设置单元格类型的话,可以按照table的区域来设置就行,比如你说的第一列,
sheet.getRange(table.startRow()+1,table.startColumn(),table.endRow()-1,1).cellType(new GC.Spread.Sheets.CellTypes.ComboBox());
Richard.Ma 发表于 2022-11-7 17:24
如果是要设置单元格类型的话,可以按照table的区域来设置就行,比如你说的第一列,
{
"version": "15.1.1",
"sheetCount": 1,
"customList": [],
"sheets": {
"Sheet1": {
"name": "Sheet1",
"isSelected": true,
"activeRow": 4,
"activeCol": 1,
"visible": 1,
"frozenTrailingRowStickToEdge": true,
"frozenTrailingColumnStickToEdge": true,
"theme": "Office",
"data": {
"dataTable": {
"5": {
"1": {
"style": {
"cellType": {
"typeName": "7",
"items": [
{ "text": "Oranges", "value": "A01" },
{ "text": "Apples", "value": "A02" },
{ "text": "Grape", "value": "A03" }
]
}
}
}
},
"6": {
"1": {
"style": {
"cellType": {
"typeName": "7",
"items": [
{ "text": "Oranges", "value": "A01" },
{ "text": "Apples", "value": "A02" },
{ "text": "Grape", "value": "A03" }
]
}
}
}
},
"7": {
"1": {
"style": {
"cellType": {
"typeName": "7",
"items": [
{ "text": "Oranges", "value": "A01" },
{ "text": "Apples", "value": "A02" },
{ "text": "Grape", "value": "A03" }
]
}
}
}
},
"8": {
"1": {
"value": "合计:",
"style": {
"cellType": {
"typeName": "7",
"items": [
{ "text": "Oranges", "value": "A01" },
{ "text": "Apples", "value": "A02" },
{ "text": "Grape", "value": "A03" }
]
}
}
}
},
"9": {
"1": {
"style": {
"cellType": {
"typeName": "7",
"items": [
{ "text": "Oranges", "value": "A01" },
{ "text": "Apples", "value": "A02" },
{ "text": "Grape", "value": "A03" }
]
}
}
}
},
"10": {
"1": {
"style": {
"cellType": {
"typeName": "7",
"items": [
{ "text": "Oranges", "value": "A01" },
{ "text": "Apples", "value": "A02" },
{ "text": "Grape", "value": "A03" }
]
}
}
}
},
"11": {
"1": {
"style": {
"cellType": {
"typeName": "7",
"items": [
{ "text": "Oranges", "value": "A01" },
{ "text": "Apples", "value": "A02" },
{ "text": "Grape", "value": "A03" }
]
}
}
}
}
},
"defaultDataNode": { "style": { "themeFont": "Body" } }
},
"rowHeaderData": {
"defaultDataNode": { "style": { "themeFont": "Body" } }
},
"colHeaderData": {
"defaultDataNode": { "style": { "themeFont": "Body" } }
},
"leftCellIndex": 0,
"topCellIndex": 0,
"selections": {
"0": { "row": 4, "rowCount": 1, "col": 1, "colCount": 1 },
"length": 1
},
"rowOutlines": { "items": [] },
"columnOutlines": { "items": [] },
"cellStates": {},
"states": {},
"outlineColumnOptions": {},
"autoMergeRangeInfos": [],
"tables": [
{
"name": "Tab_1",
"row": 4,
"col": 1,
"rowCount": 5,
"colCount": 4,
"showFooter": true,
"expandBoundRows": true,
"style": {
"wholeTableStyle": {
"backColor": "white",
"foreColor": "black",
"font": "10pt arial",
"borderLeft": { "style": 1 },
"borderTop": { "style": 1 },
"borderRight": { "style": 1 },
"borderBottom": { "style": 1 },
"borderHorizontal": { "style": 1 },
"borderVertical": { "style": 1 }
}
},
"autoGenerateColumns": false,
"bindingPath": "table1",
"rowFilter": {
"range": { "row": 5, "rowCount": 3, "col": 1, "colCount": 4 },
"typeName": "HideRowFilter",
"dialogVisibleInfo": {},
"filterButtonVisibleInfo": {
"0": true,
"1": true,
"2": true,
"3": true
},
"showFilterButton": true,
"filteredOutRows": [],
"tableName": "Tab_1"
},
"columns": [
{ "id": 1, "name": "Column1", "footerValue": "合计:" },
{ "id": 2, "name": "Column2" },
{ "id": 3, "name": "Column3" },
{ "id": 4, "name": "Column4" }
]
}
],
"index": 0
}
},
"sheetTabCount": 0
}
代码执行后,只是给单元格设置为下拉框,并没有给table列设为combobox格式 Richard.Ma 发表于 2022-11-7 17:24
如果是要设置单元格类型的话,可以按照table的区域来设置就行,比如你说的第一列,
{
"version": "15.1.1",
"sheetCount": 1,
"customList": [],
"sheets": {
"Sheet1": {
"name": "Sheet1",
"isSelected": true,
"visible": 1,
"frozenTrailingRowStickToEdge": true,
"frozenTrailingColumnStickToEdge": true,
"theme": "Office",
"data": {
"dataTable": {},
"defaultDataNode": { "style": { "themeFont": "Body" } }
},
"rowHeaderData": {
"defaultDataNode": { "style": { "themeFont": "Body" } }
},
"colHeaderData": {
"defaultDataNode": { "style": { "themeFont": "Body" } }
},
"leftCellIndex": 0,
"topCellIndex": 0,
"selections": {
"0": { "row": 0, "rowCount": 1, "col": 0, "colCount": 1 },
"length": 1
},
"rowOutlines": { "items": [] },
"columnOutlines": { "items": [] },
"cellStates": {},
"states": {},
"outlineColumnOptions": {},
"autoMergeRangeInfos": [],
"tables": [
{
"name": "tableSales",
"row": 0,
"col": 0,
"rowCount": 2,
"colCount": 1,
"style": { "buildInName": "Medium4" },
"autoGenerateColumns": false,
"bindingPath": "sales",
"rowFilter": {
"range": { "row": 1, "rowCount": 1, "col": 0, "colCount": 1 },
"typeName": "HideRowFilter",
"dialogVisibleInfo": {},
"filterButtonVisibleInfo": { "0": true },
"showFilterButton": true,
"filteredOutRows": [],
"tableName": "tableSales"
},
"columns": [
{
"id": 5,
"name": "Delivered",
"cellType": {
"typeName": "7",
"items": [
{ "text": "Oranges", "value": "11k" },
{ "text": "Apples", "value": "15k" },
{ "text": "Grape", "value": "100k" }
]
},
"dataField": "isDelivered"
}
]
}
],
"index": 0
}
},
"sheetTabCount": 0
}
我想实现类似这种列绑定 目前没法获取到table中绑定的columns信息,所以只能是你再第一次设置绑定列的时候,将列的属性保存起来,然后后面重新绑定的时候在去拿到这个信息来做绑定(包括定义的单元格类型) Richard.Ma 发表于 2022-11-7 18:53
目前没法获取到table中绑定的columns信息,所以只能是你再第一次设置绑定列的时候,将列的属性保存起来,然 ...
嗯嗯,了解,这个在后续版本会做支持么?
页:
[1]
2