By numbering, if you mean column display ordering, then you can refer:
Example table «USERS»
1. № (1) ID (field) – AUTO_INCREMENT (in SQL table)
2. USER (2) ID_USER (field)
3. NM (3) ID_NUM (field)
1). ID_USER / NAME / ID_NUM / PRODUCT
1 Joy 1 cola
1 Joy 2 pepsi
1 Joy 3 …..
2). ID_USER NAME ID_NUM PRODUCT
2 Jim 1 fanta
2 Jim 2 manta
2 Jim 3 …..
2 Jim ….
……
$rows = $stmt->fetch(PDO::FETCH_ASSOC);
$ID_NUM = $rows[‘ID_NUM’];
…..
$ID_N = $ID_NUM + 1;
$col = array();
$col[“title”] = “NM”;
$col[“name”] = “ID_NUM”;.
$col[“editable”] = true;
$col[“hidden”] = false;
$col[“editoptions”] = array(“defaultValue” => $ID_N); <—?
$cols[] = $col;
I need each group “ID_USER” to have its own numbering with saving in the table “USERS”. I get if you refresh the entire page of the site “F5”, not just “grid”
Please refer this ticket:
Works if there are records in the database. If the base is empty-does not work. How best to check if there are no records.
Hi Abu!
demo https://lttr.ru/k/max_1.php
In the clients table there is a field “clients_id” AS autoincrement, and the script works on it. If you add the field “id_num” AS integer to the table and assign max(id_num)+1.
If there are no records in the table, you must first manually add the sequence number 1, and then the script works. I need to work on any field, not just on autoincrement.
Instead of using max(id_num)+1 …. you can use:
ifnull(max(id_num),0)+1 … so if it return null for empty table, it will make it 0 and then you will get 1.
Code demo: https://gist.github.com/gridphp/27e1f4b009e2a838be0bfc49d66e0d0f#file-grid_get_max_id-php-L28