Comments (3)
应该可以结合合并单元格的能力来实现 @Rui-Sun 可以给个示例
from vtable.
const VGroup = VTable.VGroup;
const VText = VTable.VText;
const VRect = VTable.VRect;
const VTag = VTable.VTag;
const option = {
container: document.getElementById('container'),
columns: [
{
field: 'bloggerId',
title: 'bloggerId'
},
{
field: 'bloggerName',
title: 'bloggerName',
width: 150
},
{
field: 'fansCount',
title: 'fansCount',
fieldFormat(rec) {
return rec.fansCount + 'w';
},
style: {
fontFamily: 'Arial',
fontSize: 12,
fontWeight: 'bold'
}
},
{
field: 'worksCount',
title: 'worksCount',
style: {
fontFamily: 'Arial',
fontSize: 12,
fontWeight: 'bold'
}
},
{
field: 'viewCount',
title: 'viewCount',
fieldFormat(rec) {
return rec.fansCount + 'w';
},
style: {
fontFamily: 'Arial',
fontSize: 12,
fontWeight: 'bold'
}
},
{
field: 'viewCount',
title: 'viewCount',
fieldFormat(rec) {
return rec.fansCount + 'w';
},
style: {
fontFamily: 'Arial',
fontSize: 12,
fontWeight: 'bold'
}
},
{
field: '',
title: 'operation',
width: 100,
icon: ['favorite', 'message']
}
],
records: [
{
bloggerId: 1,
bloggerName: 'Virtual Anchor Xiaohua',
bloggerAvatar: 'https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/custom-render/flower.jpg',
introduction:
'Hi everyone, I am Xiaohua, the virtual host. I am a little fairy who likes games, animation and food. I hope to share happy moments with you through live broadcast.',
fansCount: 400,
worksCount: 10,
viewCount: 5,
city: 'Dream City',
tags: ['game', 'anime', 'food']
},
{
bloggerId: 2,
bloggerName: 'Virtual anchor little wolf',
bloggerAvatar: 'https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/custom-render/wolf.jpg',
introduction:
'Hello everyone, I am the virtual anchor Little Wolf. I like music, travel and photography, and I hope to explore the beauty of the world with you through live broadcast.',
fansCount: 800,
worksCount: 20,
viewCount: 15,
city: 'City of Music',
tags: ['music', 'travel', 'photography']
},
{
bloggerId: 3,
bloggerName: 'Virtual anchor bunny',
bloggerAvatar: 'https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/custom-render/rabbit.jpg',
introduction:
'Hello everyone, I am the virtual anchor Xiaotu. I like painting, handicrafts and beauty makeup. I hope to share creativity and fashion with you through live broadcast.',
fansCount: 600,
worksCount: 15,
viewCount: 10,
city: 'City of Art',
tags: ['painting', 'handmade', 'beauty makeup']
},
{
bloggerId: 4,
bloggerName: 'Virtual anchor kitten',
bloggerAvatar: 'https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/custom-render/cat.jpg',
introduction:
'Hello everyone, I am the virtual host Kitty. I am a lazy cat who likes dancing, fitness and cooking. I hope to live a healthy and happy life with everyone through the live broadcast.',
fansCount: 1000,
worksCount: 30,
viewCount: 20,
city: 'Health City',
tags: ['dance', 'fitness', 'cooking']
},
{
bloggerId: 5,
bloggerName: 'Virtual anchor Bear',
bloggerAvatar: 'https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/custom-render/bear.jpg',
introduction:
'Hello everyone, I am the virtual host Xiaoxiong. A little wise man who likes movies, reading and philosophy, I hope to explore the meaning of life with you through live broadcast.',
fansCount: 1200,
worksCount: 25,
viewCount: 18,
city: 'City of Wisdom',
tags: ['Movie', 'Literature']
},
{
bloggerId: 6,
bloggerName: 'Virtual anchor bird',
bloggerAvatar: 'https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/custom-render/bird.jpeg',
introduction:
'Hello everyone, I am the virtual anchor Xiaoniao. I like singing, acting and variety shows. I hope to be happy with everyone through the live broadcast.',
fansCount: 900,
worksCount: 12,
viewCount: 8,
city: 'Happy City',
tags: ['music', 'performance', 'variety']
}
],
defaultRowHeight: 40,
customMergeCell: (col, row, table) => {
if (col >= 1 && col < 4 && row === table.rowCount - 2) {
return {
range: {
start: {
col: 1,
row: table.rowCount - 2
},
end: {
col: 4,
row: table.rowCount - 2
}
},
customLayout: args => {
const { table, row, col, rect } = args;
const { height, width } = rect || table.getCellRect(col, row);
const container = (
<VGroup
attribute={{
id: 'container',
width,
height,
}}
>
<VRect
attribute={{
id: 'rect1',
x: 100,
height,
width: 90,
fill: 'red',
}}
></VRect>
<VText attribute={{
x: 120,
y: 25,
id: 'text1',
fill: '#000',
text: 'VisActor',
fontSize: 14,
fontFamily: 'sans-serif',
}}></VText>
<VRect
attribute={{
fill: 'blue',
id: 'rect2',
width: 90,
height,
x: 190,
}}
></VRect>
<VText attribute={{
x: 200,
y: 25,
id: 'text2',
fill: '#000',
text: 'VisActor1',
fontSize: 14,
fontFamily: 'sans-serif',
}}></VText>
</VGroup>
);
return {
rootContainer: container,
renderDefault: false
};
}
};
}
}
};
const instance = new VTable.ListTable(document.getElementById(CONTAINER_ID), option);
window.tableInstance = instance;
可以贴到站点试一下https://www.visactor.io/vtable/demo/custom-render/custom-merge-layout
from vtable.
![image](https://private-user-images.githubusercontent.com/11405152/334624655-736d6d01-b04a-4a00-85b5-a5900031473f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk0MTIzODMsIm5iZiI6MTcxOTQxMjA4MywicGF0aCI6Ii8xMTQwNTE1Mi8zMzQ2MjQ2NTUtNzM2ZDZkMDEtYjA0YS00YTAwLTg1YjUtYTU5MDAwMzE0NzNmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI2VDE0MjgwM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWZlODM3NmM3NDQ3YzNkM2FiY2I4MGQ0ZWEzYTVmZjAwNzNiOGY2YmNlYWI5NWJjMzFlZDk2OWJiZjBiZWMzNmYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Vz9mYz13jTVMB4CeyX19F6KXvY0YHGxT2DRiLSZLfiU)
嗯 我考虑过了用 customMergeCell 来指定合并单元格,但是这样会对单元格的选中有影响,合并单元格后再选中就会出现跨列了,我打算把列再多分一些,一天再划分四格,再做单元格合并。这样效果应该就可以了。谢谢 [Rui-Sun]的回答
from vtable.
Related Issues (20)
- [Bug] error when editing table header
- [Bug] 自定义布局方法value不应处理默认值 HOT 2
- [Bug] 鼠标按下后移动鼠标,不触发onMouseMoveCell、onMouseEnterCell HOT 1
- [Bug] 明细表大批量数据时,使用heightMode: "autoHeight", 多次滑动滚动轴后,页面出现白屏 HOT 1
- [Feature] react-vtable实例支持配置emptyTip
- [Feature] 透视表通过setRecords方式更新数据源时 emptyTip需要动态更新
- [Bug] Vtable> BaseTable.getCellRect 右侧固定列,但整体宽度不足时,仍然给出固定列的坐标
- [Bug] 单元格设置 api 触发编辑,可能会出现高亮态不消失问题
- [Bug] 透视表拖拽改变指标列宽后点击排序,表格宽度发生变化,并出现空白区域 HOT 2
- [Bug] 按Enter退出单元格编辑状态,先触发onChangeValue,然后才触发onKeyDown,这触发的先后顺序不太合理 HOT 1
- [Bug] option中自定义customRender或customLayout时,导致cpu100%页面卡顿
- [Bug] 自定义编辑器validateValue方法返回false时仍能点击选中其他单元格 HOT 1
- 基础数据表格-树结构-更改hierarchyExpandLevel的值,调用updateOption不生效 HOT 2
- [Feature] 批量移动行 HOT 1
- [Bug] `selected_clear` event not triggered as expected.
- Is whether there exists an API for exporting HTML? HOT 3
- 导出excel功能优化[Feature]
- TypeError: Cannot read properties of undefined (reading 'cellType') HOT 1
- [Feature] ListTable column support hide
- [Bug] column配置冲突, 定义customRender后导致icon配置失效 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vtable.