Comments (6)
So this is a bit of a limitation with my grid for now. It doesn't support multi-column index primary keys. Only primary keys based on 1 column.
Is it possible to build your table to have 1 column be your primary key? Instead of a combination of all of them?
Thanks!
from openjs-grid.
With my litle knowledge I'm trying to make it work with complex PK's
I'm checking grid.php I noteced:
function load() {
$post = $this->_safeMysql();
// setup variables from properties
$joins = $this->joins;
$fields = $this->fields;
$where = $this->where;
$table = $this->table;
// we need to break this up for use
$colsArray = explode(",",$post['cols']);
that $post['cols'] have not defined before
Notice: Undefined index: cols in C:\wamp\www\sr_trf\OpenJS-Grid-master\rmk_imp\grid.php on line 237
Unknown column 'tr_all_emp.' in 'field list'.
if you notice also it's giving an empty column:
'tr_all_emp.' ' so in order it's using empty column :
SELECT tr_all_emp
.EMPLOYID
,tr_all_emp
.ENAME
FROM tr_all_emp
ORDER BY `` asc
the grid is working but I don't know if this have affect on another thing in the grid class
from openjs-grid.
Well, the cols is a POST sent from the grid, you should check the ajax and see if its sending columns, to fix this, you might have to trace the grid loading. Pretty much all parts of the PHP deal with that primary key. Including using it as the row id/
from openjs-grid.
Now complex PK's working for update I do these modification :
function getPrimaryKey($table=NULL,$col_name=NULL) {
if(!$table) $table = $this->table;
$primaryKey = mysql_query("SHOW KEYS FROM `$table` WHERE Key_name = 'PRIMARY' AND Column_name = '$col_name'");
$primaryKey = mysql_fetch_assoc($primaryKey);
return $primaryKey['Column_name'];
}
function save() {
$saveArray = $this->getSaveArray();
// we need a primary key for editing
//$primaryKey = $this->getPrimaryKey();
// die here if a primary is not found
//if(empty($primaryKey)) die("Primary Key for table {$this->table} Not set! For inline editing you must have a primary key on your table.");
// go through each row and perform an update
foreach($saveArray as $rowId=>$row) {
$setArray = array();
$setArray2 = array();
foreach($row as $key=>$value) {
// don't update this row if you have security set
// idea from youtube user jfuruskog
if(!is_array($this->security) || in_array($key,$this->security)) {
// dont save fields that weren't saveable. i.e. joined fields
if(in_array($key,$_POST['saveable'])) {
$key = mysql_real_escape_string($key);
//$col_name=$key;
$t=$this->table;
$value = mysql_real_escape_string($value);
$setArray[] = "`$key`='$value'";
$pk= $this->getPrimaryKey($table=$t,$col_name=$key);
if($pk){
$setArray2[] = " `$key`='$value' and ";
}
}
}
}
//$sql = "UPDATE {$this->table} SET ".implode(",",$setArray)." WHERE `$primaryKey` = '$rowId'";
$sql = "UPDATE {$this->table} SET ".implode(",",$setArray)." WHERE ".implode(" ",$setArray2)." 1=1";
$res = mysql_query($sql);
// die with messages if fail
$this->dieOnError($sql);
}
return (bool) $res;
}
from openjs-grid.
Hi Ram,
Even after the change as you said above, still I get the same error as bellow.
Error :
Notice: Undefined index: cols in C:\xampp\htdocs\Regression\lib\openjs\grid.php on line 247
Unknown column 'script_details.' in 'field list'
Kindly can you please clear this.
from openjs-grid.
as optikalefx commented 2 months ago
Well, the cols is a POST sent from the grid, you should check the ajax and see if its sending columns, to fix this, you might have to trace the grid loading. Pretty much all parts of the PHP deal with that primary key. Including using it as the row id/
mentioned when it's called from grid.js there no errors.
from openjs-grid.
Related Issues (20)
- Drag & Drop Option in OpenJS Grid HOT 2
- No users table in sample.sql HOT 5
- Select drop-down to fill all rows on a column HOT 3
- Visible rows HOT 4
- Column width when grid is opend
- Support Chinese (or non-English language) HOT 1
- openJs-Grid Support For ASP.NET MVC
- No copyright in grid.php HOT 1
- Loading forever HOT 7
- populate an OpenJS grip based on the value HOT 1
- How to join multi tables with INNER JOIN to view desired columns from tables HOT 4
- undefined console.log(value, columnOpts, grid); HOT 6
- Conversion/update to PDO HOT 58
- Search Box issues and bugs
- Blank Row Allow HOT 1
- Grid class pass query instead of tablename HOT 2
- How to change and save column type image value in database HOT 4
- I am trying to achieve group view functionality as shown in picture can u help in that. Thanks in advance HOT 2
- how can i make this work with codeigniter?
- No database selected HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openjs-grid.