Creating a sortable table using jQuery and Laravel
When handling large amounts of data, it can be helpful to display it in a table view. To manipulate the data, such as for sorting or searching, we can use the data tables JavaScript library. This way, we don't need to keep making database calls every time we want to change the view.
Getting ready
For this recipe, we need a standard installation of Laravel and a properly configured MySQL database.
How to do it...
Follow the given steps to complete this recipe:
In our database, create a new table and add some example data using the following commands:
DROP TABLE IF EXISTS bookprices; CREATE TABLE bookprices (id int(10) unsigned NOT NULL AUTO_INCREMENT,price float(10,2) DEFAULT NULL,book varchar(100) DEFAULT NULL,PRIMARY KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO bookprices VALUES ('1', '14.99', 'Alice in Wonderland'); INSERT INTO bookprices VALUES ('2', '24.50', 'Frankenstein'); INSERT INTO bookprices VALUES ('3', '29.80', ...