javascript - enable/disable 'add new' button in jquery jtable -
i using jquery jtable display tables mysql db. in 1 of tables, want user allowed insert 1 row. i.e. disable add new record
button once first row inserted.
is possible this?
i have following structure defined jtable:
$('#schooltablecontainer').jtable({ title : 'schools list', paging: true, //enable paging pagesize: 10, //set page size (default: 10) sorting: true, //enable sorting defaultsorting: 'name asc', //set default sorting actions : { listaction : 'controlleradminschool?action=list', createaction : 'controlleradminschool?action=create', updateaction : 'controlleradminschool?action=update', deleteaction : 'controlleradminschool?action=delete' }, fields : { id : { title : 'school id', key : true, list : false }, name : { title : 'name' }, address : { title : 'address' }, email : { title : 'email' }, phone : { title : 'phone' }, website : { title : 'website' }, remark : { title : 'remark' } } }); $('#schooltablecontainer').jtable('load');
similarly can enable/disable edit
& delete
buttons individually each row depending upon condition (e.g. if name
has particular value admin
disable delete)?
also how add custom button in each row (e.g. view details can click on view
button , can view full details of corresponding row)?
to dynamically disable "add new record" functionality can remove button defining function handling recordsloaded event:
recordsloaded: function(event, data) { var rowcount = data.records.length; if (rowcount>=1){ $('#tablecontainer').find('.jtable-toolbar-item.jtable-toolbar-item-add-record').remove(); } }
similarly, keep behavior of table coherent should implement same kind of logic events rowinserted , rowsremoved.
i'm aware it's dom fiddling rather controlling behavior of jtable stop offering action, hikalkan's (jtable's author) answer here leads me believe it's preferred approach.
- for custom buttons on each row implement first solution described here.
Comments
Post a Comment