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

Cannot implement custom sorting by column: columns.sortable.compare missing on react implementation #633

Open
gonzaloenterrios opened this issue Jun 13, 2020 · 7 comments
Labels
Discussion Technical discussion, questions, input needed Enhancement New feature of an existing functionality or an improvement of an existing functionality pkg:Grid

Comments

@gonzaloenterrios
Copy link

I'm submitting a Suggestion for improvement.

I implemeted a Kendo React Grid containing objects with the following structure:
{
createdon: "2020-03-27T16:59:52Z"
createdon_formatted: "3/27/2020 5:59 PM"
id: "91b96a5e-4c70-ea11-80f0-20474790ab5d"
ofs_ruleid: {
Id: "15734fa9-5779-e811-80d6-20474790ab5c"
LogicalName: "ofs_routingrule"
Name: "Validate Individual"
}
ofs_success: false
ofs_success_formatted: "No"
}

One of the columns I defined is using the ofs_ruleid field which is an object, so I implemented the cell property on the Column to use the Id, LogicalName and Name sub properties to create the td tag.
This is working fine, but the problem is that when I try to sort by that field (ofs_ruleid) it doesn't work cause it's an object and not a primitive value like string or dates.
I read that on the JQuery version you can define a compare function on the columns property sortable.compare(https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/configuration/columns.sortable#columnssortablecompare) but this is not abailable on Kendo React Grids.

Is there any workaround for this?

Thanks

@TrevorJamesH
Copy link

I'd like to extend this to grouping as well. I need to be able to group by one field, then sort those groups by another field.

@andreoliveira56
Copy link

I am having the same issue. I am trying to sort the columns by natural order and I can't override the compare function.
The only option is to re-do the whole sort comparison on onSortChange which is not good at all. Or is there an easy way to achieve this?

Thanks!

@simonssspirit simonssspirit added Discussion Technical discussion, questions, input needed Enhancement New feature of an existing functionality or an improvement of an existing functionality pkg:Grid labels Sep 22, 2020
@simonssspirit
Copy link
Contributor

This will be possible after this is implemented: #819

@francisu
Copy link

+1 for extending this to grouping. See: https://feedback.telerik.com/kendo-react-ui/1523636-need-to-be-able-to-have-more-control-over-the-order-of-groups-in-the-kendo-grid-sort-on-the-text-is-insufficient

@simonssspirit
Copy link
Contributor

558718 - Requested again to be able to make custom sort inside a group.

@samir-byte
Copy link

does anyone find any solution for this issue ?

@gabo71096
Copy link

gabo71096 commented Dec 5, 2023

I noticed this when trying to customize the sorting function

image

dataState is just this:

const [dataState, setDataState] = useState<State>({
  skip: 0,
  take: 25,
  sort: [{ field: "oas_submissiondate", dir: "desc" }],
});

so apparently we could use this to make our own sorting function, I haven't used it yet, will post here if I have any success.

EDIT:

You can do this, and you take control of the sorting ⚡

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion Technical discussion, questions, input needed Enhancement New feature of an existing functionality or an improvement of an existing functionality pkg:Grid
Projects
None yet
Development

No branches or pull requests

7 participants