Add form is empty

QuestionsAdd form is empty
Amir asked 7 years ago

Hi, I am new user of phpgrid, evaluating it before license purchase.

I have a table with following fields:
id, personname, phone, email, dt
id field is unique auto increment.
dt field is timestamp with default of current_timestamp.

My code looks like this:

$g->table = "salespeople_sp";
$col = array();

$col["title"] = "Name";
$col["name"] = "personname";
$cols[] = $col;

$col["title"] = "Phone";
$col["name"] = "phone";
$cols[] = $col;

$col["title"] = "E-Mail";
$col["name"] = "email";
$cols[] = $col;

$col["title"] = "ID";
$col["name"] = "id";
//$col["viewable"] = false;
$col["hidden"] = true;
$cols[] = $col;

$col["title"] = "Date";
$col["name"] = "dt";
$col["viewable"] = false;
$col["hidden"] = true;
$cols[] = $col;

$g->set_columns($cols);
$out = $g->render("list1");

My problems are:
If I put the code for id column above the code for name column then the grid doesn't render with any value.

I am unable to edit the grid at all.
I am enable to add records. When I press the + button I get the popup with "Add Record" in header and two buttons, Submit & Cancel.

What am I doing wrong here?

Where can I find more examples of code?

Thanks
Amir

5 Answers
Amir answered 7 years ago

I have solved this problem, however I still have another one.
The first field in my grid is defined as follows:

$col = array();

$col["title"] = "active"; // caption of column
$col["name"] = "active"; // grid column name, same as db field or alias from sql
$col["viewable"] = true;
$col["hidden"] = false;
$col["editable"] = true;
$col["edittype"] = "select"; // render as select
$col["editoptions"] = array("value"=>'0:No;1:Yes');
$cols[] = $col;

The second field is defined as follows:
$col["title"] = "Name"; // caption of column
$col["name"] = "personname"; // grid column name, same as db field or alias from sql
$col["viewable"] = true;
$cols[] = $col;

There are a few other fields set like the one above.
the problem is that when I try to edit a record, ALL the fields look like they are set to be in select mode.

It is as if the values of the previous field are not reset.

Amir answered 7 years ago

For prosperity and for the same of future searchers, the initialization of each $col must be done per column/field.

If you look at the code above you will see I only have
$col = array();
once and not for every column. Once the above line was entered in the code for each column all the reported issues were resolved.

Abu Ghufran answered 7 years ago

Thanks for sharing amir.

Vincenzo answered 6 years ago

How you have solved the problem of empty ADD box?

I have the same problem.

Abu Ghufran answered 6 years ago

You need to set each editable column as

$col["editable"] = true;
$cols[] = $col;

Your Answer

12 + 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?