$multirow_operations won't reflect at grid immediately.

Talk about implementation of multirow operations

Moderator: alexandrleonenko

follower
Senior
Senior
Posts: 27
Joined: Feb 10th, '09, 14:13

$multirow_operations won't reflect at grid immediately.

Postby follower » Oct 15th, '09, 07:53

My problem:

After I use custom action to update the items from the query view, it won't show the reflected latest update immediately.

Example: row 2, field a show value= "333"

I want to update it a to "123"

So, I click on 'TriggerUpdate'. After clicked, it do update successfully into db, but the grid still show 333. I need to manually refresh thewhole page again to see the latest data at grid.

What's wrong with my code?
I believe its due to the binding sequence of some sort of similar concept.

Help.

Here's a complete code sequence for your review.

Appreciate if you can help me out.



$sql= "select id, a, b from table1";

$debug_mode = grid_debugmode;
$messaging = true;
$unique_prefix = "f_";
$dgrid = new DataGrid($debug_mode, $messaging, $unique_prefix, DATAGRID_DIR);


$default_order_field = "id";
$default_order_type = "ASC";
$dgrid->dataSource($db_conn, $sql, $default_order_field, $default_order_type);


$dg_encoding = "utf8";
$dg_collation = "utf8_unicode_ci";
$dgrid->setEncoding($dg_encoding, $dg_collation);

$dg_language = "en";
$dgrid->setInterfaceLang($dg_language);

$direction = "ltr";
$dgrid->setDirection($direction);

$layouts = array("view"=>0, "edit"=>1, "filter"=>1);
$dgrid->setLayouts($layouts);

$modes = array(
"add" =>array("view"=>$full_access, "edit"=>false, "type"=>"link"),
"edit" =>array("view"=>$full_access, "edit"=>true, "type"=>"link", "byFieldValue"=>""),
"cancel" =>array("view"=>true, "edit"=>true, "type"=>"link"),
"details" =>array("view"=>true, "edit"=>false, "type"=>"link"),
"delete" =>array("view"=>$full_access, "edit"=>true, "type"=>"image")
);
$dgrid->setModes($modes);



$multirow_option = true;
$dgrid->allowMultirowOperations($multirow_option);
$multirow_operations = array(
"delete" => array("view"=>true),
"details" => array("view"=>true),
"TriggerUpdate" => array("view"=>true, "tooltip"=>"Update table1", "image"=>"../../../../../images/UpdateNow.gif")
);
$dgrid->setMultirowOperations($multirow_operations);


$sorting_option = true;
$dgrid->allowSorting($sorting_option);

$paging_option = true;
$rows_numeration = false;
$numeration_sign = "N #";
$dgrid->allowPaging($paging_option, $rows_numeration, $numeration_sign);

$vm_colimns = array(
"id" =>array("header"=>"ID", "type"=>"label", "align"=>"left", "width"=>"130px", "wrap"=>"nowrap", "text_length"=>"-1", "case"=>"normal", "summarize"=>false, "on_js_event"=>""),
"a" =>array("header"=>"b", "type"=>"label", "align"=>"left", "width"=>"130px", "wrap"=>"nowrap", "text_length"=>"-1", "case"=>"normal", "summarize"=>false, "on_js_event"=>""),
"b" =>array("header"=>"a", "type"=>"label", "align"=>"left", "width"=>"130px", "wrap"=>"nowrap", "text_length"=>"-1", "case"=>"normal", "summarize"=>false, "on_js_event"=>"")
);


$dgrid->setColumnsInViewMode($vm_colimns);


$table_name = "table1";
$primary_key = "id";
$condition = "";
$dgrid->setTableEdit($table_name, $primary_key, $condition);



$mode = (isset($_GET['f_mode'])) ? $_GET['f_mode'] : ""; //cancel, edit, details, update
$o_rid = (isset($_GET['f_rid'])) ? $_GET['f_rid'] : "";

if(isset($_GET[$unique_prefix.'mode']) && ($_GET[$unique_prefix.'mode'] == "TriggerUpdate") )
{
$dgrid->bind(false);

$rid = explode("-", $_GET['f_rid']);

for($j=0; $j< $i_rid; $j++)
{
$sql= "update table1 set a="123" where id='" . $rid[$j] . "' ";
$result = mysql_query ($sql);
}

}

$dgrid->bind(true);
ob_end_flush();

administrator
Site Admin
Site Admin
Posts: 6011
Joined: Jan 7th, '09, 23:18
Contact:

Re: $multirow_operations won't reflect at grid immediately.

Postby administrator » Oct 17th, '09, 20:21

There is nothing to do:
or you need to recall bind()
or you need to perform your UPDATE before calling the DataGrid.

follower
Senior
Senior
Posts: 27
Joined: Feb 10th, '09, 14:13

Re: $multirow_operations won't reflect at grid immediately.

Postby follower » Oct 18th, '09, 01:12

I actually tried with few ways, it's not working...


Method1:
If I rebind, it results in 2 grid shown at browser, where the second grid is in infinite loading mode.


Method2:
If I update before calling the datagrid, it is not reflected at all,
if(isset($_GET[$unique_prefix.'mode']) && ($_GET[$unique_prefix.'mode'] seems not found before calling the datagrid

If I put after ob_start, after $dgrid = new DataGrid($..... It will update, but it won't reflect immediately.

In this case, since I already posted the full sample code in this thread, do you mind to edit the code in the thread (bold your addition/deletion of code) to show me and all supporter on how to make this work?

Instant updated data show upon customaction called is quite important for me.

follower
Senior
Senior
Posts: 27
Joined: Feb 10th, '09, 14:13

Re: $multirow_operations won't reflect at grid immediately.

Postby follower » Oct 18th, '09, 02:28

Seems like I found the way to solve it. :lol:

The custom action must be placed after $dgrid = new DataGrid($debug_mode, $messaging, $unique_prefix, DATAGRID_DIR); and before $dgrid->dataSource($db_conn, $sql, $default_order_field, $default_order_type);

bradkb
Newbie
Newbie
Posts: 9
Joined: Jun 9th, '09, 18:46

Re: $multirow_operations won't reflect at grid immediately.

Postby bradkb » Oct 29th, '09, 12:19

Tried your method for mine, but that appeared not to work, my fix is -


at the end of my custom multirow put the following -


echo "<meta http-equiv='refresh' content='0;URL=xxxxxxxx.php'>";

where xxxxxxx is the current page, it simply does the operation and refreshes the page, works great.

avga2000
Junior
Junior
Posts: 14
Joined: Mar 15th, '09, 19:37

Re: $multirow_operations won't reflect at grid immediately.

Postby avga2000 » Dec 1st, '09, 18:13

Let me share my technique:

....
....
....
....
$dgrid->bind();
ob_end_flush();

if(isset($_GET[$unique_prefix.'mode']) && ($_GET[$unique_prefix.'mode'] == "xxxxxx") )
{
...
...
$new_str = str_replace("xxxxxx","view",$_SERVER['REQUEST_URI']);
echo "<script>document.location.href='".$new_str."';</script>";
}

where xxxxxx is the multirow operation name.

I hope it can helps you.

administrator
Site Admin
Site Admin
Posts: 6011
Joined: Jan 7th, '09, 23:18
Contact:

Re: $multirow_operations won't reflect at grid immediately.

Postby administrator » Dec 2nd, '09, 16:37

if you want to redirect page - use $dgrid->bind(false);


Return to “Settings: multirow operations”