jquery - display tables row according to drop down value -
i want increase or decrease rows of table selecting number of rows drop down
for example if have select 25 drop down table show first 25 rows only
i want use plugin . not know how can use this
this code jsfiddle
$('#nrows').change(function(){ rows = $(this).val(); alert(rows + ' number of rows displayed using plugin' ); $('#table').datatable(); });
please tell me how can display selected number of rows
if you're doing @ initialization, you'd use pagelength
property:
$('#nrows').change(function () { rows = $(this).val(); $('#table').datatable({'pagelength':rows}); });
jsfiddle: http://jsfiddle.net/wmfax/4/
that being said, work first time initialize datatable; after that, you'll want update page length via api , redraw table. if try use above more once, you'll error stating "cannot reinitialise datatable" after second time toggle nrows
dropdown.
here quick & dirty example of initializing datatable outside change handler , changing page length inside of it: http://jsfiddle.net/wmfax/6/
i'd recommend against creating own nrows
select dropdown though; it's easy enough in datatables customize theirs , don't have worry collisions between 2 or overriding ui.
Comments
Post a Comment