Index with two cells

QuestionsIndex with two cells
fersan asked 8 years ago

Hi, I need help!!! I have a table with INDEX = codalbaran, numlinea, (name PRIMARY), The Grid Works perfect, it show me all but it don't delete or edit. I read about custom delete but I don't find more information.

$col = array();
$col["title"] = "Id"; // caption of column
$col["name"] = "codalbaran, numlinea"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)

or changes for this and also it works but the same problem

$col["name"] = "PRIMARY"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)

$col["width"] = "10";
$col["hidden"] = true;
$cols[] = $col;

5 Answers
Abu Ghufran answered 8 years ago

For composite keys – there are two possible approaches:

1) Creating a new AUTO_INCREMENT column directly in the database, so that each row has a unique id, then using this column for primary key. You can hide the column using hidden => true.

2) In your SELECT statement (select_command), you may try to select a first column as special concat value

e.g. select concat(codalbaran, '-', numlinea) as pk …

that is based on composite keys. This will handle the listings. For updates, you need to manually manage on_update or on_insert code using custom events (as in demos/editing/custom-events.php)

In callbacks, you can split this key, and execute insert/update/delete queries manually.

fersan answered 8 years ago

Thanks I try concate or custom-events.

fersan answered 8 years ago

HI I try

$g->select_command = "SELECT * FROM (SELECT i.codalbaran, i.numlinea, c.referencia, c.descripcion, i.cantidad, i.importe, CONCAT(i.codalbaran, '-', i.numlinea) as codnum FROM pedidoslineatmp i INNER JOIN articulos c ON i.codigo = c.codarticulo WHERE i.codalbaran= '$pid') o";

and the Grid show the CONCAT but the same problem, don't edit, update…

$col = array();
$col["title"] = "Id"; // caption of column
$col["name"] = "codnum"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
$col["width"] = "20";
//$col["hidden"] = true;
$cols[] = $col;

Could you write complete URL?

…demos/editing/custom-events.php (I don't find it)

fersan answered 8 years ago

$g->table = "pedidoslineatmp";

Abu Ghufran answered 8 years ago

The demo can be found in full package archive, demos/editing/custom-events.php
If you are using free version, custom events are not supported.

Your Answer

9 + 4 =

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?