课程: Design the Web: Creating a Sortable Table

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Creating custom sort properties

Creating custom sort properties

- [Voiceover] Now we're going to focus our attention on the date column. Now if I come over here and click on the date, it's going to sort the date, but it's going to sort it based on the first letter of the month in the text that's part of the TD tag. So the issue here is that when we don't have enough data inside of this TD element for JavaScript to determine the exact date so the plugin in turn cannot sort these in chronological order. So as I mentioned before, one option is you can put the dates in these particular formats so that the user sees these particular dates and the plugin will be able to sort these chronologically. However, I want to use my own custom labels. I don't want to have a particular time and I don't want to use a number format. So what we're going to do instead is use our own custom labels, anything that we want, and we're going to sort based on a data attribute. So back in the HTML file, inside of our table element, inside of the table body, I have a data-date…

内容