jQWidgets Forums
jQuery UI Widgets › Forums › Grid › MySql data – foreign key
This topic contains 3 replies, has 2 voices, and was last updated by usrimas 11 years, 3 months ago.
-
AuthorMySql data – foreign key Posts
-
Hi,
I want to do foreign key solution as here : ( http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/index.htm#demos/jqxgrid/foreignkeycolumn.htm ) . But it seems that this is working only with xml data types – I didn’t understand how it can be related with MySql json data …
Can you post some source how this can be done with data form MySql tables ?
Then it’s other solution – gridkeyvaluescolumnwitharray.htm . But … Mine foreign key values are ~ 800 records . Trying to edit this field it tooks ~ 0,5 minute before get appears ( at first time )… Slow … or it’s normal ?
Hi usrimas,
The data source does not matter. It works with any data types. However, we do not have a sample with JSON at present. Note that parsing of XML is much slower compared to parsing of JSON. That is normal.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comThanks,
I’ll try foreign key solution as in your sample …
Need some help with foreign key …
Foreign table :
var prekSource = { datatype : "json", datafields: [ { name: 'preke', type: 'string' }, { name: 'pav_lt', type: 'string' } ], id : 'preke', url : "dmas.php?qry=select preke,pav_lt from prekes where prek_tipas='Gaminys' and db='" + $app_db+ "' order by preke&fld=preke,pav_lt", async : false, root : 'Rows' }; var prekAdapter = new $.jqx.dataAdapter( prekSource, { autoBind : true, beforeLoadComplete: function( records ) { var data = new Array(); for ( var i = 0; i < records.length; i++ ) { data[ i ] = records[ i ]; } return data; } });
It’s OK, data filled .
Main source :
var source = { dataType : 'json', cache : false , datafields : col_adp, // array of cols is returned from other function ... id : pagr_fld, root : 'Rows', beforeprocessing : function( data ){ source.totalrecords = data[ 0 ].TotalRows; }, url : uzkl, sort : function(){ $( "#" + mygrd ).jqxGrid( 'updatebounddata', 'sort' ); }, filter : function(){ $( "#" + mygrd ).jqxGrid( 'updatebounddata', 'filter' ); } }; // debugger; // adding foreign key as from sample ... u = findElement( col_adp, "name", 'preke' ); col_adp[ u ].map = 'm\\:properties>d\\:preke'; col_adp[ u ].values = { source: prekAdapter.records, name: 'preke' }; // I'm seeing that prekAdapter have values
But that return error : Uncaught TypeError: Cannot read property ‘preke’ of undefined . What I’m missing here ?
Thanks in advance !
-
AuthorPosts
You must be logged in to reply to this topic.