refresh a listgrid

hello,

i have a listgrid that takes the data from a php file like this:

isc.ListGrid.create({
         .........,
         data: [ <?php   include("deleteUser_js.php");	  ?> ]
});

i have a button that add a new user and it sends to a database via a php file, and a button that deletes the users that i choose, also delete it from the database via php file.

the problem is:

  1. i add a new user (it works ok)
  2. i push the Delete button, and it opens a window with a listgrid inside containing the users, the new user added before is not in the listgrid.

only if i push refresh on the whole application it apears in the delete listgrid.

so…how can i do refresh to the listgrid?..
i read somewhere something about Timer.setTimeout… where to put it and how to use it?..
thank you

Please do search for RestDataSource it will be in your best interests! Trust me on this one!

in a nutshell:

isc.RestDataSource.create({
    ID:"dbDS",
    fields: [{name:"id", title:"ID", type:"integer", primaryKey:true, canEdit:false},
{name:"field1", title:"field1"},
{name:"field2", title:"field2"}],
    showPrompt:false,
    fetchDataURL:"db.php?menu=<?=$menuObj['id']?>",
    addDataURL :"db.php?menu=<?=$menuObj['id']?>",
    updateDataURL:"db.php?menu=<?=$menuObj['id']?>",
    removeDataURL:"db.php?menu=<?=$menuObj['id']?>"
});

isc.ListGrid.create({
         .........,
    fields: [{name:"id", title:"ID", type:"integer", primaryKey:true, canEdit:false},
{name:"field1", title:"field1"},
{name:"field2", title:"field2"}],
        dataSource: dbDS,
        canEdit:true,
        editEvent: "doubleClick",
        modalEditing:true      
});

when the listgrid is populated it’s getting the records from fetchDataURL file, when you delete it’s using removeDataURL, etc.

I put this this sao you can know that you can specify difrent files for each operation

    fetchDataURL:"db.php?menu=<?=$menuObj['id']?>",
    addDataURL :"db.php?menu=<?=$menuObj['id']?>",
    updateDataURL:"db.php?menu=<?=$menuObj['id']?>",
    removeDataURL:"db.php?menu=<?=$menuObj['id']?>"

but you can just use

    dataURL:"db.php?menu=<?=$menuObj['id']?>"

in db.php you get the operationtype by $_POST[‘_operationType’]

Again search the docs and the Feature Explorer for RestDataSource.

thanks for the answer, i will try this, hope to succed because it looks a little bit complicated…

but it’s now another posibility not to change my code?..

oh,
there a lots of possibilities … but at the end of the day you’ll find out that you’ve taken a nasty u-turn :))

For eg: you could use RPCManager to send your data ( but this is like scraching in your left ear with your right hand)

pls tell me who should be ‘menu’ and ‘menuObj’

so…my code looks like this:

isc.RestDataSource.create({
    ID:"dbDS",
    fields: [{name:"Nume", title:"Nume"} ],
    //showPrompt:false,
      dataURL:"fetchUsers.php",
      fetchDataURL:"fetchUsers.php"
  
});


isc.ListGrid.create({
	fields: [      {name:"Nume", title:"Nume"} ],
        dataSource: dbDS,
	autoFetchData:true,
        width:150,
	ID:"ListGrid1"		
});

and the php:

<?php
.........include....

$strOutput ="{Nume:ceva},{Nume:care},{Nume:NuMerge}";	 
echo $strOutput;

?>

so…it doesn’t do anything. what is the problem?..

“…menu=<?=$menuObj[‘id’]?>” it was intended to show that you could set some get params in the URL :slight_smile:

As it is showed in the docs RestDataSource SmartClient expects that fetchUsers.php to be in a specific format:

 <response>
    <status>0</status>
    <data>
      <record>
          <field1>value</field1>
          <field2>value</field2>
      </record>
      <record>
          <field1>value</field1>
          <field2>value</field2>
      </record>
    </data>
 </response>

and in your case:

<?
.........include....

?>

<response>
    <status>0</status>
    <data>

<?php
echo '<record>'."\r\n";
echo '   <Nume>nume</Nume>'."\r\n";
echo '</record>'."\r\n";
echo '<record>'."\r\n";
echo '   <Nume>care</Nume>'."\r\n";
echo '</record>'."\r\n";
echo '<record>'."\r\n";
echo '   <Nume>Merge</Nume>'."\r\n";
echo '</record>'."\r\n";
?>
    </data>
 </response>

so… i tried what you said, and it works, but i have a problem

in my Delete Users Window… i have 2 listgrids.
1st listgrid must contain the users from the DB.
2nd listgrid containes the users selected to be deleted. (this is done by pushing a button that moves the field selected from the 1st listgrid to the second one).

and when i push the big buton DELETE it must delete all the users that apear in the listgrid2 from the database.

so..the problem with RestDataSource (RDS)…is that when i push ‘move’ to the 2nd listgrid, i have to delete it from the RDS and so…i have to work on the database all the time. and i don’t want this. i want to work staticly…
how can i do to just import the data, move the data between the listgrids, and after, when i push the button DELETE, to delete from the database???..

or…it is possible to save the DataURL received from the php file in an array that looks like the fields of a listgrid??..like this:“{Nume:“Gica”},{Nume:“Popa”}”