« Grid4php::04-docs selecting-columns » : différence entre les versions

De wiki_pcwiki2
Aller à la navigationAller à la recherche
Page créée avec « KEYWORDS: GRID4PHP, DOCUMENTATION '''Le 14/02/2024: documentation pour grid4php »
 
Aucun résumé des modifications
 
Ligne 2 : Ligne 2 :


  '''Le 14/02/2024: documentation pour grid4php
  '''Le 14/02/2024: documentation pour grid4php
Selecting Columns
By default, when we define the ->table property, it displays all the columns of table.
We can pick certain columns to be displayed on grid by using ->set_columns($cols) function.
$col = array();
$col["title"] = "Id"; // caption of column, can use HTML tags too
$col["name"] = "client_id"; // grid column name, same as db field or alias from sql
$col["width"] = "20"; // width on grid
$col["editable"] = true;
$cols[] = $col;
$col = array();
$col["title"] = "Name"; // caption of column, can use HTML tags too
$col["name"] = "name"; // grid column name, same as db field or alias from sql
$col["width"] = "40"; // width on grid
$col["editable"] = true;
$cols[] = $col;
$col = array();
$col["title"] = "Gender"; // caption of column, can use HTML tags too
$col["name"] = "gender"; // grid column name, same as db field or alias from sql
$col["width"] = "60"; // width on grid
$col["editable"] = true;
$cols[] = $col;
// pass the cooked columns to grid
$g->set_columns($cols);
If you want to customize any specific column properties, and let other columns be displayed from table definition, you can pass 2nd argument of set_columns($cols,true) to true.
$col = array();
$col["name"] = "company";
$col["edittype"] = "textarea";
$cols[] = $col;
$g->set_columns($cols,true);
Only column with name 'company' will be changed to textarea and rest table column will be displayed as they were before.
NOTE: The first column must have unique data (usually PK) in order to work properly. It is required to identify and perform row wise operations. You can make it hidden in  grid if you wish. See hidden property in later section for more.
Resources
    Sample Code
    See Live Demo
    You can check this demo in archive demos/appearance/image.php

Dernière version du 14 février 2024 à 11:31

KEYWORDS: GRID4PHP, DOCUMENTATION

Le 14/02/2024: documentation pour grid4php
Selecting Columns

By default, when we define the ->table property, it displays all the columns of table. 
We can pick certain columns to be displayed on grid by using ->set_columns($cols) function.

$col = array();
$col["title"] = "Id"; // caption of column, can use HTML tags too
$col["name"] = "client_id"; // grid column name, same as db field or alias from sql
$col["width"] = "20"; // width on grid
$col["editable"] = true;
$cols[] = $col;

$col = array();
$col["title"] = "Name"; // caption of column, can use HTML tags too
$col["name"] = "name"; // grid column name, same as db field or alias from sql
$col["width"] = "40"; // width on grid
$col["editable"] = true;
$cols[] = $col;

$col = array();
$col["title"] = "Gender"; // caption of column, can use HTML tags too
$col["name"] = "gender"; // grid column name, same as db field or alias from sql
$col["width"] = "60"; // width on grid
$col["editable"] = true;
$cols[] = $col;

// pass the cooked columns to grid
$g->set_columns($cols); 

If you want to customize any specific column properties, and let other columns be displayed from table definition, you can pass 2nd argument of set_columns($cols,true) to true.

$col = array();
$col["name"] = "company";
$col["edittype"] = "textarea";
$cols[] = $col;

$g->set_columns($cols,true);

Only column with name 'company' will be changed to textarea and rest table column will be displayed as they were before.

NOTE: The first column must have unique data (usually PK) in order to work properly. It is required to identify and perform row wise operations. You can make it hidden in  grid if you wish. See hidden property in later section for more.
Resources

   Sample Code
   See Live Demo
   You can check this demo in archive demos/appearance/image.php