Call to undefined method jqgrid::get_dropdown_values()

QuestionsCall to undefined method jqgrid::get_dropdown_values()
Mark M asked 9 years ago

Hi All

I'm probably doing something blindingly stupid but I just can't see it.

Any idea why I'm getting "Call to undefined method jqgrid::get_dropdown_values()" ??

I had some working sample code using phpgrid 1.4.6
I've just upgraded to 1.5.2 and my build grid fails when I try to include a column based on a query using $g->get_dropdown_values(). I get method is not defined. I've searched though jgrid_dist.phop and cant find get_dropdown_values() !?!

If I comment out the columns which use $g->get_dropdown_values() the grid builds fine (with missing columns though)

A sample of one of the columns is..
(The $test line was there for me to check the contents of the string before passing to the grid object)

$col = array();
$col["title"] = "Section"; // Column Heading
$col["name"] = "fk_section"; // Field name
$col["dbname"] = "section.id";
$col["edittype"] = "select"; // render as select
$test = "select id as k, name as v from ".TBL_SECTION." where fk_type = $type";
$str = $g->get_dropdown_values($test);
$col["editoptions"] = array("value"=>$str);
$col["formatter"] = "select"; // show label in grid, instead of value
$col["editable"] = true;
$col["search"] = false;
$cols[] = $col;

Many Thanks

Mark

9 Answers
Abu Ghufran answered 9 years ago

Make sure $g = new jqgrid() object and define before calling $g->get_dropdown_values().

Mark M answered 9 years ago

Hi Abu
Sorry if my original query was not clear.

The object is already created and defined properly. Remember this is the same code that worked prior to me upgrading phpgrid.

I left out the object creation code from the snippet above to concentrate on the column causing me problems

The grid draws properly if I comment out the column using $g->get_dropdown_values

When I include the column I get the undefined error.

I have more than one column using dropdown but for this example I've remove them and just left a single dropdown column called "Section"

Currently Section is commented out and the grid draws

The full code is :-

$g = new jqgrid();

// set few params
$grid["caption"] = "Exam Candidates";
$grid["autowidth"] = true;
$g->set_options($grid);

// set database table for CRUD operations
$g->table = TBL_EXAMLINE;
$g->select_command = "Select * from " . TBL_EXAMLINE . " where fk_exam = 1";

// Build Columns array containing formatting and editing details
// $col = array of a single column details
// $cols = array of $col
$col = array();
$col["title"] = "ID"; // Column Heading
$col["name"] = "id"; // Field name
$col["width"] = 80;
$col["editable"] = false;
$col["search"] = false;
$cols[] = $col;

$col = array();
$col["title"] = "Exam FK"; // Column Heading
$col["name"] = "fk_exam"; // Field name
$col["width"] = 80;
$col["editable"] = true;
$col["hidden"] = true;
$col["editoptions"] = array("size"=>5, "defaultValue"=>1);
$col["search"] = false;
$cols[] = $col;

$col = array();
$col["title"] = "Examinee Name"; // Column Heading
$col["name"] = "name"; // Field name
$col["width"] = 200;
$col["editable"] = true;
$col["search"] = false;
$cols[] = $col;

/* $col = array();
$col["title"] = "Section"; // Column Heading
$col["name"] = "fk_section"; // Field name
$col["dbname"] = "section.id";
$col["edittype"] = "select"; // render as select
$test = "select id as k, name as v from ".TBL_SECTION." where fk_type = 1";
$str = $g->get_dropdown_values($test);
$col["editoptions"] = array("value"=>$str);
$col["formatter"] = "select"; // show label in grid, instead of value
$col["editable"] = true;
$col["search"] = false;
$cols[] = $col;
*/
$col = array();
$col["title"] = "Examiner"; // Column Heading
$col["name"] = "fk_examiner"; // Field name
$col["dbname"] = "examiner.id";
$col["edittype"] = "select"; // render as select
$str = "0:None;".$g->get_dropdown_values("select id as k, name as v from ".TBL_EXAMINER);
$col["editoptions"] = array("value"=>$str);
$col["formatter"] = "select"; // show label in grid, instead of value
$col["editable"] = true;
$col["viewable"] = true;
$col["search"] = false;
$cols[] = $col;

$col = array();
$col["title"] = "Price (£)"; // Column Heading
$col["name"] = "price"; // Field name
$col["width"] = 80;
$col["formatter"] = "currency";
$col["formatoptions"] = array("prefix" => "£");
$col["editoptions"] = array("defaultValue"=>"0.00");
$col["editable"] = true;
$col["viewable"] = true;
$col["search"] = false;
$cols[] = $col;

$col = array();
$col["title"] = "Action"; // Column Heading
$col["name"] = "act"; // Field name $col["width"] = 120;
$col["search"] = false;
$cols[] = $col;

$g->set_columns($cols); // Set Column Data

$out = $g->render("list1"); // render grid and get html/js output

Abu Ghufran answered 9 years ago

Your code looks fine. Now it looks like you are including free version of library, as this function is supported in full version now.
As an alternate solution, you can execute the query and form the query results in this format:

key1:value1; key2:val2; key3:val3

And set this string in $str for array("value"=>$str);

Mark M answered 9 years ago

Thanks Abu,
that explains it nicely

Cheers

Mark

Mark M answered 9 years ago

Thanks Abu,
that explains it nicely

Cheers

Mark

Mark M answered 9 years ago

Thanks Abu,
that explains it nicely

Cheers

Mark

Abu Ghufran answered 9 years ago

Yes, the events are supported in paid version.
The get_one function is part of v2.0.
If you are using older version, you can call manual php code to make db connection and do your code.

pierre mata answered 9 years ago

ihave the same problem, (undefined method jqgrid::get_one()),by the way this error not happen if i run from my pc (localhost), if i run from web, the error happen…
this if the code:

$e["on_insert"] = array("add_foto2", null, true);
$e["on_update"] = array("add_foto", null, true);

$grid->set_events($e);

function add_foto2(&$data){
global $grid;
$check_sql = "SELECT MAX(id) as c FROM fotos";
$rs = $grid->get_one($check_sql);
….

pierre mata answered 9 years ago

by the way, supposed to be i have a pay version…

Your Answer

15 + 11 =

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?