scallio
thanks for that. however, the function causes an errror of undefined or not an object. i have pasted the code i am using from the tutorial and would be grateful if you could explain the error please. many thanks for your time.
<script type=“text/javascript”>
$(function() {
$(“#flex1”).flexigrid(
{
url: ‘staff.php’,
dataType: ‘json’,
colModel : [
{display: ‘ID’, name : ‘id_con’, width : 40, sortable : true, align: ‘left’},
{display: ‘Name’, name : ‘name_con’, width : 150, sortable : true, align: ‘left’},
{display: ‘Email’, name : ‘email_con’, width : 150, sortable : true, align: ‘left’},
{display: ‘Phone’, name : ‘phone_con’, width : 250, sortable : true, align: ‘left’},
{display: ‘Mobile’, name : ‘mobile_con’, width : 150, sortable : true, align: ‘left’},
{display: ‘Fax’, name : ‘fax_con’, width : 150, sortable : true, align: ‘left’},
{display: ‘Notes’, name : ‘notes_con’, width : 250, sortable : true, align: ‘left’}
],
buttons : [
{name: ‘Edit’, bclass: ‘edit’, onpress : doCommand},
{name: ‘Delete’, bclass: ‘delete’, onpress : doCommand},
{separator: true}
],
searchitems : [
{display: ‘Name’, name : ‘name_con’},
{display: ‘Email’, name : ‘email_con’, isdefault: true},
{display: ‘Position’, name : ‘position’}
],
sortname: “name_con”,
sortorder: “asc”,
usepager: true,
title: “Staff”,
useRp: true,
rp: 10,
showTableToggleBtn: false,
resizable: false,
autowidth: true,
autoheight: true,
singleSelect: true
}
);
});
function doCommand(com, grid) {
if (com == ‘Edit’) {
$(‘.trSelected’, grid).each(function() {
var id_con = $(this).attr(‘id_con’);
id_con = id_con.substring(id_con.lastIndexOf(‘row’)+3);
alert("Edit row " + id_con);
});
} else if (com == ‘Delete’) {
$(‘.trSelected’, grid).each(function() {
var id_con = $(this).attr(‘id_con’);
id_con = id_con.substring(id_con.lastIndexOf(‘row’)+3);
alert("Delete row " + id_con);
}); }}
</script>