3

I want a dandelion datatable to show 15 rows at a time instead of the default 10 rows. Can someone show me how to accomplish this?

Here is some code that I displaying 10 rows at a time with pagination controls to scroll between sets of 10 rows:

<datatables:table id="mydata" data="${mydataset}" cdn="true" row="mr" theme="bootstrap2" 
    cssClass="table table-striped" paginate="true" info="false" 
    cssStyle="width: 150px;" align="left" dom="frtp">
    <datatables:column title="Concept Type" cssStyle="width: 150px;" display="html">
        <c:out value="${mr.something}"/>
    </datatables:column>
</datatables:table>
tduchateau
  • 4,351
  • 2
  • 29
  • 40
CodeMed
  • 9,527
  • 70
  • 212
  • 364

1 Answers1

5

You can use lengthChange attribute which allows user to select the size of a formatted page from a select menu (sizes are 10, 25, 50 and 100)

this property will only work when paginate="true"

if you don't want to show dropdown and would like change it to 15 then you override below property

global.feature.displayLength=15

default value of above property is 10 thatswhy you are its showing 10 result.

please use below code and give a try

<datatables:table id="mydata" data="${mydataset}" cdn="true" row="mr" theme="bootstrap2" 
    cssClass="table table-striped" paginate="true"  info="false" 
    cssStyle="width: 150px;" align="left" dom="frtp" lengthChange="true">
    <datatables:column title="Concept Type" cssStyle="width: 150px;" display="html">
        <c:out value="${mr.something}"/>
    </datatables:column>
   <datatables:prop name="feature.displayLength" value="15" />
</datatables:table>

How to Override ??

  • you can add a file called datatables.properties at the root of the classpath, allowing you to redefine every property you need. Your custom global configuration will then be merged with the default one.
  • Or you can locally override properties using the <datatables:prop> JSP tag. Just define the property's name and value.
Gautam
  • 3,276
  • 4
  • 31
  • 53
  • +1 and Thank you. I changed your code to indicate paginate=false, then tried your suggestion. Since there are only 14 rows in my dataset, I cannot tell whether or not your lengthChange tag did anything in addition to the paginate=false. But I am marking this as the answer because for my fixed length dataset, it solved the problem of getting everything on one page. – CodeMed May 12 '14 at 19:59
  • I am trying to get my dandelion datatable to only populate after the user has entered at least three characters into the search box. Are you willing to help me with this new question also? here is the link: http://stackoverflow.com/questions/23662863/speed-up-data-access-in-a-search-form/23663075?noredirect=1#comment36349362_23663075 – CodeMed May 14 '14 at 20:01
  • New versions are not working I am using dandelion 1.1.1 having problem http://stackoverflow.com/questions/37834638/dandelion-datatables-ajax-url-is-not-working – prem30488 Jun 16 '16 at 06:37