VTable icon indicating copy to clipboard operation
VTable copied to clipboard

[Bug] 开启了行号后如果自定义排序方法就会报错,官方例子能复现这个问题

Open xjcallen opened this issue 5 months ago • 4 comments

Version

1.7.7

Link to Minimal Reproduction

1

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: 'Order ID', title: 'Order ID', width: 'auto', sort:true, showSort:true, }, { field: 'Customer ID', title: 'Customer ID', width: 'auto', sort:(a,b,order)=>{ if (a === '') return 0 return a > -Infinity && b > -Infinity ? (roder === 'desc' ? b - a : a - b) : (roder === 'desc' ? b.localeCompare(a) : a.localeCompare(b)) }, }, { 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',
  rowSeriesNumber: {
    title: '序号',
    dragOrder: true,
    width: 'auto',
    headerStyle: {
      color: 'black',
      bgColor: 'pink'
    },
    style: {
      color: 'red'
    }
  }
};
tableInstance = new VTable.ListTable(document.getElementById(CONTAINER_ID), option);
window['tableInstance'] = tableInstance;

});

Current Behavior

如果使用事件也会报错 tableInstance.on('sort_click', ({field, order}) => { tableInstance.setRecords(reportConfig.options.records, {sortState: null}) tableInstance.updateSortState({field, order}, false) })

Expected Behavior

search-component-CQtN3nGQ.js:214 Uncaught TypeError: Cannot read properties of undefined (reading 'id') at cC.getCellId (search-component-CQtN3nGQ.js:214:38646) at hC (search-component-CQtN3nGQ.js:214:23475) at cC.getCellRange (search-component-CQtN3nGQ.js:214:40291) at InjectedListTable.getCellRange (search-component-CQtN3nGQ.js:213:108651) at jb (search-component-CQtN3nGQ.js:118:88722) at Vb (search-component-CQtN3nGQ.js:118:89056) at Qb.updateSortIcon (search-component-CQtN3nGQ.js:118:105088) at search-component-CQtN3nGQ.js:118:183583 at Array.forEach () at N1.triggerSort (search-component-CQtN3nGQ.js:118:183549)

Environment

- OS:windows
- Browser:google 125
- Framework:vtable

Any additional comments?

1

xjcallen avatar Sep 23 '24 06:09 xjcallen