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

Set the data-sortvalue value dynamically? #35

Closed
tetsujin1979 opened this issue Oct 4, 2022 · 1 comment
Closed

Set the data-sortvalue value dynamically? #35

tetsujin1979 opened this issue Oct 4, 2022 · 1 comment
Assignees

Comments

@tetsujin1979
Copy link

tetsujin1979 commented Oct 4, 2022

Is it possible to set the "data-sortvalue" value dynamically?
As in, pass in a call to a javascript function, e.g. <td data-sortvalue="textToNumber('Text')">Text</td>
where the textToNumber() function converts text to a value used in sorting?

@myspace-nu myspace-nu self-assigned this Oct 5, 2022
@myspace-nu myspace-nu added the wontfix This will not be worked on label Oct 5, 2022
@myspace-nu
Copy link
Owner

You can set the data-sortvalue value with JavaScript using the dataset
document.querySelector("#my_table_cell").dataset.sortvalue = "somevalue"
or using jQuery attr
$("#my_table_cell").attr("data-sortvalue","somevalue")

You can also hijack the sort function and write your own sort function not limited to the data-sortvalue attribute

$("#your_table").fancyTable({
	sortFunction: function(a, b, fancyTableObject, rowA, rowB){
		// your custom sort logic
	},
	// more settings
})

Closing this ticket since it is not an fancyTable issue.

@myspace-nu myspace-nu added Not an issue and removed wontfix This will not be worked on labels Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants