weixin_39657249
2020-12-31 03:27 阅读 1

DataGridColumn Filter issue

Describe the bug Every time I use this: <DataGridColumn Filterable="true"> I get errors in the browser console, which looks like this:

blazor.webassembly.js:1 WASM: Unhandled exception rendering component: blazor.webassembly.js:1 WASM: Microsoft.JSInterop.JSException: element.addEventListener is not a function blazor.webassembly.js:1 WASM: TypeError: element.addEventListener is not a function

However, the filter function actually works. I think it's a bug but maybe I don't use it properly.

Also, Maybe the DataGrid Columns needs to add server-side filtering.

该提问来源于开源项目:stsrki/Blazorise

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

7条回答 默认 最新

  • weixin_39726971 weixin_39726971 2020-12-31 03:27

    Not sure why it would give you an error. Filterable property is by default set to true. How do you handle your data? Do you read it from memory all at once, or do you load it dynamically on ReadData event?

    点赞 评论 复制链接分享
  • weixin_39657249 weixin_39657249 2020-12-31 03:27

    I read it from memory all at once.

    cshtml
    <datagrid titem="Account" data="" showpager="false" filterable="true" rowdoubleclicked="(e => OnAccountClick(e.Item as Account))" narrow="true">
    
                <datagridcolumn titem="Account" field="(Account.AccountNumber)" caption="IBan" sortable="true" filterable="true">
                </datagridcolumn>
                <datagridcolumn titem="Account" field="(Account.Ccy)" caption="Currency" sortable="true" filterable="true"></datagridcolumn></datagrid>
    

    This is how I do it.

    点赞 评论 复制链接分享
  • weixin_39657249 weixin_39657249 2020-12-31 03:27

    In this case I have small data.

    点赞 评论 复制链接分享
  • weixin_39726971 weixin_39726971 2020-12-31 03:27

    Maybe one of your fields is a complex type. For example is Ccy in Account.Ccy a string or is it a class or struct type? In case it is a complex type, then you need to define full "path". eg Account.Ccy.Name.

    点赞 评论 复制链接分享
  • weixin_39657249 weixin_39657249 2020-12-31 03:27

    No. I commented out all the other columns and left just this AccountNumber column and still have the same errors in console.

    点赞 评论 复制链接分享
  • weixin_39726971 weixin_39726971 2020-12-31 03:27

    Can you please provide me with the small repro project so I can have a better look?

    点赞 评论 复制链接分享
  • weixin_39657249 weixin_39657249 2020-12-31 03:27

    Thanks for the help.

    I played a little bit and found that I hadn't set up Blazor properly.

    点赞 评论 复制链接分享

相关推荐