Is your example code suppose to match your examples?

Talk about any other operations you need to implement: additions, updates etc.

Moderator: alexandrleonenko

ethanthomas82
Junior
Junior
Posts: 22
Joined: Jan 22nd, '12, 23:35

Is your example code suppose to match your examples?

Postby ethanthomas82 » Jan 26th, '12, 08:03

RADIO BUTTON
I am trying to get both radio buttons and drop downs working in the Add/Edit/Details Mode Settings and your examples are making it difficult.
In your example 2-8, you have in the Add/Edit/Details Mode Settings for "field_enum" as source:
"source"=>$fill_from_array
Where is the value(s) set for $fill_from_array? I can not find a definition for this variable or array anywhere in the code.
So can you show me from the real code that is running your example how this variable or array is defined?

DROP DOWN
In your example 2-7, you have in the Add/Edit/Details Mode Settings for "status" you have:
$em_columns = array(
"status" =>array("header"=>"Status", "type"=>"enum", "req_type"=>"st", "width"=>"210px", "title"=>"Status", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "unique"=>false, "unique_condition"=>"", "on_js_event"=>"", "source"=>"self", "view_type"=>"dropdownlist"),
);
$dgrid->SetColumnsInEditMode($em_columns);
This populates the selections from the table for the dropdownlist in your demo.

I stated the following in my code:
$table_name = "mytablename";
$primary_key = "id";
$condition = "";
$dgrid->SetTableEdit($table_name, $primary_key, $condition);

Then I did exactly the same thing in my code as in your example:
$em_columns = array(
"laststatus" => array("header"=>"LStatus", "type"=>"enum", "req_type"=>"rt", "width"=>"200px", "title"=>"laststatus", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "unique"=>false, "unique_condition"=>"", "on_js_event"=>"", "source"=>"self", "view_type"=>"dropdownlist"),
);
$dgrid->SetColumnsInEditMode($em_columns);

Your code gives a dropdownlist with values and my code gives an empty dropdownlist. If I don't place a dropdownlist but make it a text field, it will populate the text field with the current value. But when I define a dropdownlist, it is empty. So why does the exact code work in your example and not in my code?

When I use "source"=>"self", isn't it suppose to populate the dropdown values from the table field?

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

Re: Is your example code suppose to match your examples?

Postby administrator » Jan 26th, '12, 10:36

1. Please check carefully:
$fill_from_array = array("0"=>"Banned", "1"=>"Active", "2"=>"Closed", "3"=>"Removed"); /* as "value"=>"option" */

2. "source"=>"self" retrieves distinct values from table. If your table is empty it will show empty dropdownbox.
So, sometimes with use "source"=>array(), where you may predefine all needed values

ethanthomas82
Junior
Junior
Posts: 22
Joined: Jan 22nd, '12, 23:35

Re: Is your example code suppose to match your examples?

Postby ethanthomas82 » Jan 26th, '12, 18:49

I am not sure where the code below came from but according to the webpage find (search feature), it was not there yesterday when I searched "fill_from_array". But I will check the coffee I am drinking.

$fill_from_array = array("0"=>"Banned", "1"=>"Active", "2"=>"Closed", "3"=>"Removed"); /* as "value"=>"option" */

I know I am a newbee and trying hard to learn this, but I am not going to expect an empty table to populate a dropdownbox. Your program must have a bug which isn't uncommon for programs. Just letting you know. It will not self populate. I am going to try defining array as indicated above. I expect that will work. Thank You!
Last edited by ethanthomas82 on Jan 26th, '12, 22:58, edited 1 time in total.

ethanthomas82
Junior
Junior
Posts: 22
Joined: Jan 22nd, '12, 23:35

Re: Is your example code suppose to match your examples?

Postby ethanthomas82 » Jan 26th, '12, 22:57

Now that I have error reporting on screen turned on, it gives me an error. So there definitely is a bug. The reason I didn't post this in the bug category was because I didn't realize this was a bug in the beginning. I just assumed I wasn't doing it right.

Notice: Undefined index: source in datagrid.class.php on line 6577

ethanthomas82
Junior
Junior
Posts: 22
Joined: Jan 22nd, '12, 23:35

Re: Is your example code suppose to match your examples?

Postby ethanthomas82 » Jan 27th, '12, 04:13

I tried it and the fill_from_array method works fine. As long as that method works, the self population method, while it is a neat feature, I can get by without it. Thank You!


Return to “Additional operations implementation”