optikalefx / OpenJS-Grid

OpenJS Grid is the easiest jQuery Grid ever. With very little work you can have a data grid that can do everything from sorting and searching to complex database queries. Best of all, its open source. So you can learn how it's all done.
http://square-bracket.com/openjs
MIT License
96 stars 46 forks source link

Order by and number of columns #54

Closed LawrenceWeng closed 10 years ago

LawrenceWeng commented 10 years ago

Two Questions.

  1. There doesn't seem to be a way to specify an order by. Also, at the moment it just orders by the first column. Is there any way to change that? Maybe even change it to not order by anything.
  2. There is a property 'nRowsShowing' that defaults to 10 and appears as the number of rows per page. This appears as 'showing 1 - 10'. This works fine but only shows 7 records and has a scroll bar for the next 3. How can I change this to show the full 10?

I understand that these things may be out of scope of OpenJS Grid but any points in the right direction would be greatly appreciated. Also, thank you very much for releasing this.

Alex

optikalefx commented 10 years ago

If you pass {orderBy: "someColumn", sort: "DESC"} as options into your grid call you can get an order by. nRowsShowing should work, can you show me an example page where it's doing 1-7 then 7-10?

Thanks!

LawrenceWeng commented 10 years ago

Thank you very much for the quick response. :+1:

After trying that I can see that what I'm trying to do isn't going to be simple. I am passing in a generated sql script at run time so I may not know what columns exist. Optimally my query would return a rownum as the first column. Unfortunately, mysql has no rownum feature and any attempts to replicate it require variables which I cannot use in a view. But I digress, this is a mysql problem not a shortcoming with your library.

As for the number of records showing I think this picture explains it better. In the example you have 'nRowsShowing' set to 20 but only 7 rows are shown on the screen. Records 8 - 20 are only viewable with a scrollbar. (I am a very beginner web developer so I have a feeling that this too will not be a downfall of your library.) http://imgur.com/B438tQo

Thanks again, Alex

LawrenceWeng commented 10 years ago

Additional: I can't seem to find any mention of {orderBy: "someColumn", sort: "DESC"} on your API page.

optikalefx commented 10 years ago

Yea, i need to update the docs with that. But it is in the code commented. Your image shows 7, but there is a scrollbar to show the rest of the 20. If you wanted all 20 to be "visible", just change the CSS height. nRowsShowing is === number of rows to show per page. You still have to scroll because of the fixed height.

LawrenceWeng commented 10 years ago

Thanks. The rows showing is just the CSS height (and my lack of web dev knowledge). Thanks for the order by as well. It appears that what I'm trying to do with that is not possible due to MySQL limitations.

Thanks again for OpenJS Grid!