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

[Bug] SearchComponent 结合 checkbox 使用报错 #1448

Closed
xiaoosnggao opened this issue Apr 7, 2024 · 0 comments · Fixed by #1497
Closed

[Bug] SearchComponent 结合 checkbox 使用报错 #1448

xiaoosnggao opened this issue Apr 7, 2024 · 0 comments · Fixed by #1497
Assignees
Labels
bug Something isn't working

Comments

@xiaoosnggao
Copy link
Contributor

xiaoosnggao commented Apr 7, 2024

Version

0.23.1

Link to Minimal Reproduction

https://visactor.io/vtable/demo/search/search-component

Steps to Reproduce

let  tableInstance;
fetch('https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/North_American_Superstore_data.json')
  .then((res) => res.json())
  .then((data) => {

    const columns =[
      {
          field: 'isCheck',
          title: '',
          width: 46,
          headerType: 'checkbox',
          cellType: 'checkbox',
        },
      {
          "field": "Order ID",
          "title": "Order ID",
          "width": "auto"
      },
      {
          "field": "Customer ID",
          "title": "Customer ID",
          "width": "auto"
      },
      {
          "field": "Product Name",
          "title": "Product Name",
          "width": "auto"
      },
      {
          "field": "Category",
          "title": "Category",
          "width": "auto"
      },
      {
          "field": "Sub-Category",
          "title": "Sub-Category",
          "width": "auto"
      },
      {
          "field": "Region",
          "title": "Region",
          "width": "auto"
      },
      {
          "field": "City",
          "title": "City",
          "width": "auto"
      },
      {
          "field": "Order Date",
          "title": "Order Date",
          "width": "auto"
      },
      {
          "field": "Quantity",
          "title": "Quantity",
          "width": "auto"
      },
      {
          "field": "Sales",
          "title": "Sales",
          "width": "auto"
      },
      {
          "field": "Profit",
          "title": "Profit",
          "width": "auto"
      }
    ];

    const option = {
      records:data,
      columns,
      widthMode:'standard'
    };
    const dom = document.getElementById(CONTAINER_ID);
    tableInstance = new VTable.ListTable(dom, option);
    window['tableInstance'] = tableInstance;

    const search = new SearchComponent({
      table: tableInstance,
      autoJump: true
    });
    window.search = search;

    const searchContainer = document.createElement('div');
    searchContainer.style.position = 'absolute';
    searchContainer.style.top = '0';
    searchContainer.style.right = '0';
    searchContainer.style.backgroundColor = '#FFF';
    const input = document.createElement('input');
    searchContainer.appendChild(input);
    const result = document.createElement('span');
    result.innerText = '0/0';
    searchContainer.appendChild(result);
    const searchBtn = document.createElement('button');
    searchBtn.innerText = 'search';
    searchContainer.appendChild(searchBtn);
    const nextBtn = document.createElement('button');
    nextBtn.innerText = 'next';
    searchContainer.appendChild(nextBtn);
    const prevBtn = document.createElement('button');
    prevBtn.innerText = 'prev';
    searchContainer.appendChild(prevBtn);
    searchBtn.addEventListener('click', () => {
      const searchResult = search.search(input.value);
      result.innerText = searchResult.results.length === 0 ? '0/0' : `${searchResult.index + 1}/${searchResult.results.length}`;
    });
    prevBtn.addEventListener('click', () => {
      const searchResult = search.prev();
      result.innerText = searchResult.results.length === 0 ? '0/0' : `${searchResult.index + 1}/${searchResult.results.length}`;
    });
    nextBtn.addEventListener('click', () => {
      const searchResult = search.next();
      result.innerText = searchResult.results.length === 0 ? '0/0' : `${searchResult.index + 1}/${searchResult.results.length}`;
    });
    dom.appendChild(searchContainer);
  });

Current Behavior

点击搜索报错

image

Expected Behavior

应该过滤掉非文本类型的内容,或者做一下兼容处理

Environment

- OS:macos
- Browser:chrome
- Framework:react

Any additional comments?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants