Autocomplete : not save

QuestionsAutocomplete : not save
biowan asked 11 years ago

Hi,

I followed the example in demos/integration/autocomplete. I can search value when I tape. And when I press enter to valid changes, new value is set in the input. But when I reload the grid, it stay with the old value. The update doesn't work. To add a new item, it's same. And no error on screen.

Thanks for your help.

8 Answers
Abu Ghufran answered 11 years ago

Hello,

It looks like you are having some query error in doing UPDATE.
Please check using firebug the UPDATE POST response.

Follow this link for debugging using firebug:
https://phpgrid.desk.com/customer/portal/articles/926266

biowan answered 11 years ago

Hi Abu,

No error in firebug tool. This is the reponse :
{"id":"'217'","success":true}

The id number is the record that I updated. But new value wasn't save, and old value is back after page reloaded.

Thanks for your help.

Abu Ghufran answered 11 years ago

You can now check the REQUEST tab in firebug->net … to see what actual data is posted to server for update.
This message of success means update query went fine.

You can also email code for review at my email address.

biowan answered 11 years ago

Still not work.
Is it possible to print the update query ?

Abu Ghufran answered 11 years ago

In jqgrid_dist.php file, you can search for this line and do an echo, and check in firebug.

$sql = "UPDATE {$this->table} $update_str WHERE $pk_field IN ($id)";

biowan answered 11 years ago

Table location :
id
label
type
logic_num // room number, used to search when I type in autocomplete field.

Table attribution :
id
participant_id
location_id

My select_command :
SELECT attribution.id AS id,
attribution.participant_id,
attribution.location_id,
location.logic_num AS room,
FROM attribution
INNER JOIN location ON location.id = attribution.location_id

My location field parameters :
"title" => "Location",
"name" => "room",
"editable" => true,
"search" => true,
"dbname" => "location.logic_num",
"formatter" => "autocomplete", // autocomplete
"formatoptions" => array(
"sql" => "SELECT id as k, logic_num as v FROM location",
"search_on" => "logic_num", // I wish to know if it's possible to seach in more than 1 field. Ex : Concat(firstname, ' ', lastname) AS fullname ?
"update_field" => "location_id", // I think this value must be the field in "attribution" table field name
),

The update query from jqgrid_dist.php :
UPDATE attribution SET participant_id='487' WHERE id IN ('216')

The HTTP post query indicated by Firebug :
room=R0001&participant_id=487&oper=edit&id=216

So the value participant_id was updated, firebug print me the operation was successful is correct. Because the query works fine. But the value of the room is missing in query to update. Don't know what's wrong in my parameters.

Thanks for your help.

Abu Ghufran answered 11 years ago

Please make sure you have column 'location_id' and it is set editable -> true.

$col["name"] = 'location_id';
$col["editable"] = true;

Only editable columns are posted on update. Another thing is if you are using excel view, only changed column will be posted.

biowan answered 11 years ago

Good, thanks Abu. I didn't see over in the demo sample that I must add the id field. It works now. Thanks a lot.

Your Answer

2 + 12 =

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?