添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

DataGrid SortBy Func #7597

@ncigula

Description

Bug type

Component

Component name

DataGrid

What happened?

Here you can how im using the PropertyColumn component. When i try to sort by the Bank property of my data model its not working, the Column name being sent by the data grid is CurrencyExchangeRate.MiddleRate.
I cant reproduce the same thing on trymudblazor so ill paste in an empty link. I believe i have explained everything in such detail that it can be understood without a demo and i have provided what i believe is a solution to the issue. I will also try to create a PR and try to fix it myself.

Expected behavior

I would expect that the DataGrid sends the column defined in the SortBy property instead of the one defined in the Property property. I Belive the issue is in the picture. The higlighted property called PropertyColumn has the value "CurrencyExchangeRate.MiddleRate". You should use Column.SortyBy to get the name of the column i want to sort by.
In the second picture you can see how the PropertyName is being retrieved, i believe you could retrieve the SortBy property name in the same way.

  • Column.SortBy should be changed from Func to Expression
  • Now you could use the same logic applied to Property to SortBy
  • Refactor the code in places where you currently have the call to Column.SortyBy property to call the Func. So you should have a field of type Func which u initialize like - field = SortBy.Compile(); Now you can use the func where you need. You can find those places by searching for SortBy references.
  • Reproduction link

    https://try.mudblazor.com/snippet/tVhbb-JGFH4OfyIjqw9Gapxtpb4kQCFskk21uWiN-lJV0WAmMM3YY82MAyTiv_fMxfgGJkitHwKZc5vznat5fr7HNAkEfufidJhJmsxRuJaKxMEDUcE3pdLgD8mTjqPdZ7MrppmD6xWOU0Zk8BUrHNzzGWGyM6TJPyRSSMuNGSWJQovt106nB-Ka_VbQGZr0vWtGYiB46A4Myr43dAfSQzeUKSLwlJG-p0RG8hNtCBhzLcVhMOYsixN78IMvvUEHwdOzx9L-Z06eBE-JUGtLQfm_fW-F-gO0Ch6yeEqEhyZUaesPonqbF8wkXOf8CI0hnSdewW9krMoJARCxIlWiYQCs7iKeXGVK8QQ9JgBi9AquP6bEeQm4AQMcPVP49FBI3zU2-iMIY8xY5ZZlxY9vRDC8Rn9SSY1Tw-cXo1Ir90rGfL-rXShRUR8ZBLp7lT_xlIN-pLnrmkdJtODiUd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nXvSUSb-YajVny1Yv9oqeGDmbnZXYFtOm0SNpVsOptTZyyI5GnlhwTYK7QGg-4tSSAs0WWnwjHRAdATJwhN0Og7tvO1k8CKJeG9hxz65cFeOs2msI-iiMF2lDtfQ9ixuMlsliL0geZEXSKp_2zqnBSyMd_b2jmdTr0WHlZpf2Wo8W0Z_9Jo5CucVuh70rwQdf_eY1W_RLVbnXH4BCDN_tjKeWdmPnWrWKQEhG7fTZ3IdhNx15nw0Hzx9-WqICoTCYJ3QPP6h87Qh_Zz4-1IrX8B

    Reproduction steps

  • I try to sort the CurrencyExchangeRate column and i get the explained error.
  • Relevant log output

    No response

    Version (bug)

    6.0.9

    Version (working)

    No response

    What browsers are you seeing the problem on?

    Chrome, Microsoft Edge

    On what operating system are you experiencing the issue?

    Windows

    Pull Request

  • I would like to do a Pull Request
  • Code of Conduct

  • I agree to follow this project's Code of Conduct
  •