phpgrid

Questionsphpgrid
selvamuthu asked 12 years ago

hai,

I am new to phpgrid

How can i display the lookup value of a particular column if the column editmode=”select”

please help me

selvamuthu

6 Answers
Abu Ghufran answered 12 years ago

Render as select (dropdown), with these values "key:value;key:value;key:value"

$col["edittype"] = "select";
$col["editoptions"] = array("value"=>'10:$10;20:$20;30:$30;40:$40;50:$50');

// For multiselect, you probably need to write custom on_update handler
$col["editoptions"] = array("value"=>'10:$10;20:$20;30:$30;40:$40;50:$50', "multiple" => true);

If you want these values to be database driven, or want to use autocomplete based lookup, try checking the premium version.

selvamuthu answered 12 years ago

hai,

I am new to phpgrid

How can i display the lookup value of a particular column if the column editmode=”select”

I mean i want to display the value instead of key of a "select" column

please help me

selvamuthu

selvamuthu answered 12 years ago

Ok

My Code is
$col["edittype"] = "select";
$col["editoptions"] = array("value"=>'M:Male;F:Female');

i need the value (eg. Male) in the grid view but the grid display only key (eg. M).

But this works in inline editor, in normal view it is missing.

Please help

Abu Ghufran answered 12 years ago

The display on grid is based on the Table data or SQL command you have set in grid.
Try using IF() clause in SQL that will replace M with male and so on.

selvamuthu answered 12 years ago

Thanks Mr. Abu Ghufran

I have another issue, please help me.

My Sql
select students.standardnowdoing, students.sectionnowat, standards.stdname, students.studentname from students left outer standards on students.standardnowdoing=standards.standard

ok
Now i have 3 columns
standardnowdoing, sectionnowat, stdname, studentname
1,A,"FIRST","JOHN"
1,A,"FIRST","PETER"

in php grid i need standardnowding, stdname (with "select"), studentname

please help

Abu Ghufran answered 12 years ago

Refer FAQs for help.

##### Q) How can i show lookup dropdown from other table (i.e. linked with FK data)

First step is to select the data which you want to display in grid, which will include table join.
Important thing here is to alias that data with FK field name.

// select query with FK_data as FK_id, e.g. clients.name as client_id
$g->select_command = "SELECT id, invdate, clients.name as client_id, amount, note FROM invheader
INNER JOIN clients on clients.client_id = invheader.client_id
";

After that, you need to define column like this.

$col = array();
$col["title"] = "Client";
$col["name"] = "client_id"; // same as aliased name (fk)
$col["dbname"] = "clients.name"; // this is required as we need to search in name field, not id

$col["edittype"] = "select"; // render as select

# fetch data from database, with alias k for key, v for value
$str = $g->get_dropdown_values("select distinct client_id as k, name as v from clients");
$col["editoptions"] = array("value"=>$str);

$cols[] = $col;

Refer dropdown.php for working demo.

Your Answer

2 + 20 =

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?