Giter Club home page Giter Club logo

Comments (9)

Xorpio avatar Xorpio commented on September 27, 2024

Template collumn has a property called SortBy. This should work.

look at the unit tests:
https://github.com/MudBlazor/MudBlazor/blob/dev/src/MudBlazor.UnitTests.Viewer/TestComponents/DataGrid/DataGridSortableTemplateColumnTest.razor

from mudblazor.

ProgramGeek02 avatar ProgramGeek02 commented on September 27, 2024

ok but the sortBy will only give me in the ServerReload the identifier of the column, but the way i added the column doesn't allow me to recognise the column because the identifier given to the column is a random GUID

from mudblazor.

Xorpio avatar Xorpio commented on September 27, 2024

doesnt it work if you do:
<TemplateColumn Title="@(columnName)" Class="multiline-text" SortBy="x => (string)prop.GetValue(x)">

from mudblazor.

Xorpio avatar Xorpio commented on September 27, 2024

or
<TemplateColumn Title="@(columnName)" Class="multiline-text" SortBy="@(_ => columnName)">

from mudblazor.

ProgramGeek02 avatar ProgramGeek02 commented on September 27, 2024

I need to do the order by on server side because on client side i only have part of the data due to pagination. so i need to understand on the method ServerReload what column the user selected and pass that information to the server that will do the OrderBy

from mudblazor.

Xorpio avatar Xorpio commented on September 27, 2024

you should be able to use the DataGrid MudDataGrid<TItem> object to get the SortDefinitions.

in these objects you should be able to get all the information to build a request to your server and repopulate the itmes collection

for refferences: https://mudblazor.com/api/datagrid#properties

from mudblazor.

ProgramGeek02 avatar ProgramGeek02 commented on September 27, 2024

Normally yes, but because i've created the columns using projection in foreach cycle there seems to be no way to know programmatically wich column the user want to order

from mudblazor.

ScarletKuro avatar ScarletKuro commented on September 27, 2024

Hi,

It would be nice if you attached a TryMudBlazor example to play with.

As a workaround, you can set the Title for the TemplateColumn, then get a ref of your MudDataGrid, iterate through RenderedColumns, find the TemplateColumn by that GUID, and extract the title.

from mudblazor.

ScarletKuro avatar ScarletKuro commented on September 27, 2024

Another option is to create your own TemplateColumn by inheriting Column<T> and override how the PropertyName behaves and use own logic instead of the random guid. I think all the needed tools are available.

from mudblazor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.