Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat ( sheet ): add source binding feature #4461

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

VicKun4937
Copy link
Contributor

@VicKun4937 VicKun4937 commented Jan 11, 2025

  • add source binding draft
const fWorkbook = univerAPI.getActiveWorkbook();
const fSheet = fWorkbook.getActiveSheet();

const source = fWorkbook.createSource(univerAPI.Enum.DataBindingNodeTypeEnum.Object);
source.setSourceData({
    user: {
        name: '猿婶'
    }
})

fSheet.setBindingNode(1, 2, {
    path: 'user.name',
    type: univerAPI.Enum.DataBindingNodeTypeEnum.Object,
    sourceId: source.getId()
})

const listSource = fWorkbook.createSource(workbook.getUnitId(), univerAPI.Enum.DataBindingNodeTypeEnum.List);
listSource.setSourceData({
    fields: ['商品', '种类'],
    records: [['苹果', '水果'], ['香蕉', '水果'], ['圆珠笔', '文具']]
})
fSheet.setBindingNode(1, 4, {
    path: '商品',
    type: univerAPI.Enum.DataBindingNodeTypeEnum.List,
    sourceId: listSource.getId()
})

fSheet.setBindingNode(1, 5, {
    path: '种类',
    type: univerAPI.Enum.DataBindingNodeTypeEnum.List,
    sourceId: listSource.getId()
})

@univer-bot univer-bot bot changed the title feat(sheet): add source binding feature feat ( sheet ): add source binding feature Jan 11, 2025
@univer-bot
Copy link

univer-bot bot commented Jan 11, 2025

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿

Origin Title: feat(sheet): add source binding feature

Title: feat ( sheet ): add source binding feature


  • Add source binding draft
const fWorkbook = univerAPI.getActiveWorkbook();
const fSheet = fWorkbook.getActiveSheet();

const source = fWorkbook.createSource(univerAPI.Enum.DataBindingNodeTypeEnum.Object);
source.setSourceData({
    user: {
        name: 'English'
    } }
})

fSheet.setBindingNode(1, 2, {
    path: 'user.name',
    type: univerAPI.Enum.DataBindingNodeTypeEnum.Object,
    sourceId : source . getId ( )
})

const listSource = fWorkbook.createSource(workbook.getUnitId(), univerAPI.Enum.DataBindingNodeTypeEnum.List);
listSource . setSourceData ( { { .
    fields: ['layer', 'label'],
    records: [['speech', 'speech'], ['speech', 'speed'], ['speech', 'speed']]
})
fSheet.setBindingNode(1, 4, {
    path: 'Local',
    type: univerAPI.Enum.DataBindingNodeTypeEnum.List,
    sourceId : listSource . getId ( )
})

fSheet.setBindingNode(1, 5, {
    path: 'Search',
    type: univerAPI.Enum.DataBindingNodeTypeEnum.List,
    sourceId : listSource . getId ( )
})

Copy link

View Deployment

#12724444561

🥐 🍔 🥓 🥗 🥘 🌯 🍚 🍛 🍖 🍭 🍧 🍝 🥪 🥖 🍪
Still cooking, please come back later
🥙 🥮 🥨 🌭 🍦 🍙 🍕 🍰 🍮 🍜 🍡 🍱 🍿 🍕 🥟

@VicKun4937 VicKun4937 marked this pull request as draft January 11, 2025 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant