Custom querie for virtual columns

QuestionsCustom querie for virtual columns
C3media asked 7 years ago

Hello Abu,

I have this function to get values in different tables:

function bonus_data($data)
{

$t = $data["params"]["reference_no"];

$client_id = $data["params"]["customer_id"];
global $h;
$res = $h->execute_query("select id, name, company, award_points from sma_companies WHERE id = '$client_id'");
#phpgrid_error($h->con->errormsg());
$arr = $res->GetRows();
#phpgrid_error($arr);
$document = $arr[0]["name"];
$client_name= $arr[0]["company"];
$points= $arr[0]["award_points"];

}

As this values are from table different to sales_table (grid table)
then i need it values in same grid as Virtual Columns getting Cols:

var rowid = jQuery("#list1").jqGrid("getGridParam","selrow");
var row = $("#list1").getRowData(rowid);

It's possible?

Thank you again!

3 Answers
Abu Ghufran answered 7 years ago

If your client_id is dropdown column, you can have callback function that will fill other fields of form by running query.
For detail, refer demos/appearance/dropdown-callback.php

Beside this, there is no such option in grid library.

C3media answered 7 years ago

Hello Abu,

I have been studying grid events tried this:

// virtual column to show award_points

$col = array();
$col["title"] = "Puntos";
$col["name"] = "vpuntos";
$col["width"] = "400";
$col["hidden"] = false;
$sales[] = $col;

function filter_points($data)
{
$t = $data["params"]["reference_no"];

$client_id = $data["params"]["customer_id"];
global $h;
$res = $h->execute_query("select id, name, company, award_points from sma_companies WHERE id = '$client_id'");

$arr = $res->GetRows();

$document = $arr[0]["name"];
$client_name= $arr[0]["company"];

$data["params"]["vpuntos"] = $arr[0]["award_points"];

}

Then set event so:

$e["on_data_display"] = array("filter_points", null, true);
$h->set_events($e);

I understand that event On_Data_Display is to show grid, so would have to be an option, but not show data row.

Thank you!

Abu Ghufran answered 7 years ago

This is currently not doable with on_data_display event.

Your Answer

9 + 19 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?