views:

437

answers:

2

Ive been messing with jqgrids alot of the last couple days, and I have nearly everything the way I want it from the display, tabs with different grids, etc.

Im wanting to make use of Modal for adding and editing elements on my grid. My problem that Im running into is this. I have my editurl:"editsu.php" set, if that file is renamed, on edit, i get a 404 in the modal.. great! However, with that file in place, nothing at all seems to happen. I even put a die("testing"); line at the top, so it sees the file, it just doesnt do anything with it.

Below is the content. ........ the index page

jQuery("#landings").jqGrid({
    url:'server.php?tid=1',
    datatype: "json",
    colNames:['ID','Tower','Sector', 'Client', 'VLAN','IP','DLink','ULink','Service','Lines','Freq','Radio','Serial','Mac'],
    colModel:[
        {name:'id', index:'id', width : 50, align: 'center', sortable:true,editable:true,editoptions:{size:10}},
        {name:'tower', index:'tower', width : 85, align: 'center', sortable:true,editable:false,editoptions:{readonly:true,size:30}},
        {name:'sector', index:'sector', width : 50, align: 'center',sortable:true,editable:true,editoptions:{readonly:true,size:20}},
        {name:'customer',index:'customer',  width : 175, align: 'left', editable:true,editoptions:{readonly:true,size:35}},
        {name:'vlan', index:'vlan', width : 35, align: 'left',editable:true,editoptions:{size:10}},
        {name:'suip', index:'suip', width : 65, align: 'left',editable:true,editoptions:{size:20}},
        {name:'datadl',index:'datadl', width:55, editable: true,edittype:"select",editoptions:{value:"<? $qr = qquery("select * from datatypes"); while ($q = ffetch($qr)) {echo "$q[id]:$q[name];";}?>"}},     
        {name:'dataul', index:'dataul', width : 55, editable: true,edittype:"select",editoptions:{value:"<? $qr = qquery("select * from datatypes"); while ($q = ffetch($qr)) {echo "$q[id]:$q[name];";}?>"}},
        {name:'servicetype', index:'servicetype', width : 85, editable: true,edittype:"select",editoptions:{value:"<? $qr = qquery("select * from servicetype"); while ($q = ffetch($qr)) {echo "$q[id]:$q[name];";}?>"}},
        {name:'voicelines', index:'voicelines', width : 35, align: 'center',editable:true,editoptions:{size:30}},
        {name:'freqname', index:'freqname', width : 35, editable: true,edittype:"select",editoptions:{value:"<? $qr = qquery("select * from freqband"); while ($q = ffetch($qr)) {echo "$q[id]:$q[name];";}?>"}},
        {name:'radioname', index:'radioname', width : 120, editable: true,edittype:"select",editoptions:{value:"<? $qr = qquery("select * from radiotype"); while ($q = ffetch($qr)) {echo "$q[id]:$q[name];";}?>"}},
        {name:'serial', index:'serial', width : 100, align: 'right',editable:true,editoptions:{size:20}},
        {name:'mac', index:'mac', width : 120, align: 'right',editable:true,editoptions:{size:20}}

    ],
    rowNum:20,
    rowList:[30,50,70],
    pager: '#pagerl',
    sortname: 'sid',
    mtype: "GET",
    viewrecords: true,
    sortorder: "asc",
    altRows: true,
    caption:"Landings",
    editurl:"editsu.php",
    height:420
    });
jQuery("#landings").jqGrid('navGrid','#pagerl',{edit:true,add:true,del:false,search:false},{height:400,reloadAfterSubmit:false},{height:400,reloadAfterSubmit:false},{reloadAfterSubmit:false},{});

now for the editsu.php file..

$operation = $_REQUEST['oper'];
if ($operation == "edit") {
    qquery("UPDATE customers SET vlan = '".$_POST['vlan']."', datadl = '".$_POST['datadl']."', dataul = '".$_POST['dataul']."', servicetype = '".$_POST['servicetype']."', voicelines = '".$_POST['voicelines']."', freqname = '".$_POST['freqname']."', radioname = '".$_POST['radioname']."', serial = '".$_POST['serial']."', mac = '".$_POST['mac']."' WHERE id = '".$_POST['id']."'") or die(mysql_error());
} 

Im just having a hard time troubleshooting this to figure out where its getting hung up at.

My next question after this would be to see if its possible to make it so when you click "add", that it auto inserts a row into the db with a couple variable predtermined and then bring up the modal window, but ill work on the first problem first.

thanks!

+1  A: 

I don't see a call back function anywhere. What's supposed to happen upon return of your response from server.php?

DA
Either an update or add. Id like to get a simple update of the record working first, then my next step is a multi step add, where you first search for a customer (from another sql db (i have the code for this already working in my old framework, but its a simple function), it returns a customer ID. From there, they can fill in the rest of the details.So, this function im missing, does this go up with the JS to make the grid?
Kelso
Oops. too quick to answer.. server.php is what returns the data to populate the grid. The ?tid determins which location to load data for. I am using the tabs plugin to seperate my grids, but this may change in the future,
Kelso
it gets posted to the grid, but as soon as i reload its gone. so your probably right, im missing a callback function, unfortunately im not finding any good examples to follow or even where to look..
Kelso
A: 

a few questions:

  1. does your data get updated in your database after the call to editsu.php ?
  2. can you seen the request/response in firebug's network panel ?

Jerome

Jerome WAGNER