Hi,
I have a GRID populated with data from a mysql utf8 encoded database and table. Unless I convert special characters to HTML, the xml generated become corrupt (black ? symbols appear in the place of special characters within the CDATA field in the alert with the xml content) and the grid does not shows the data. I have searched the forum and found many different things to try but so far could not find a solution.
My mysql connection is given by this file:
<?php
require_once("../dhtmlxconnector/dhtmlxConnector_php/codebase/grid_connector.php");
include("../../../includes/botanicaamazon3_clean.php");
$grid = new GridConnector($res);
$grid ->dynamic_loading(100);
$grid ->render_table("batchenter_especimenes_386_89");
?>
Tried adding line echo “<?xml version='1.0' encoding='UTF-8' ?>”; to this file and also putting the grid_connector.php in the first line of this file, as suggested somewhere.
I’ve also experimented adding the line dp.enableUTFencoding(false) in my grid file that loads the xml generated by the file above:
mygrid.loadXML(“myfile”);
dp = new dataProcessor(“myfile”);
dp.init(mygrid);
dp.enableUTFencoding(false);
My grid file has the meta charset as UTF-8…
So, everything is in UTF-8, which I use as standard!
Any suggestions?
Thanks
Beto
Are you sure that original data is a valid UTF ?
Server side generates utf-8 xml by default and it possible to specify different encoding through set_encoding command.
If data is a valid UTF, please be sure that client side page is also shown in browser as utf-8 encoded. If client side page encoding differs, the above issue may occur ( as data will be converted from utf-8 to some local encoding during rendering )
I do face same problem… did everything what I found.
In my case I am using Mysqli with codeigniter…
Problem is only with XML generated using render_sql
connector:::
function grid_listuser(){
$this->load->model(‘dhtmlx_model’);
$mysqli = $this->dhtmlx_model->connection();
$grid = new GridConnector($mysqli,“MySQLi”);
$grid->dynamic_loading(20);
$sql = “SELECT * FROM users WHERE id
!=1”;
$grid->render_sql($sql,“id”,“username,email,first_name,last_name,phone,action”);
}
model:::
public function connection(){
include_once ("dhtmlx/connector/codebase/grid_connector.php");
include_once ("dhtmlx/connector/codebase/db_mysqli.php");
$database = $this->load->database('default',TRUE);
$mysqli = new mysqli($database->hostname, $database->username, $database->password, $database->database);
return $mysqli;
}
view:::
<?php
echo link_tag('dhtmlx/dhtmlx.css');
echo link_tag('dhtmlx/dhtmlxGrid/codebase/dhtmlxgrid.css');
echo link_tag('dhtmlx/dhtmlxGrid/codebase/skins/dhtmlxgrid_dhx_web.css');
echo link_tag('dhtmlx/dhtmlxMessage/codebase/themes/message_default.css');
echo script_tag('dhtmlx/dhtmlxcommon.js');
echo script_tag('dhtmlx/dhtmlxGrid/codebase/dhtmlxgrid.js');
echo script_tag('dhtmlx/dhtmlxGrid/codebase/dhtmlxgridcell.js');
echo script_tag('dhtmlx/dhtmlxGrid/codebase/ext/dhtmlxgrid_filter.js');
echo script_tag('dhtmlx/dhtmlxDataProcessor/codebase/dhtmlxdataprocessor.js');
echo script_tag('dhtmlx/connector/codebase/connector.js');
echo script_tag('dhtmlx/dhtmlxGrid/codebase/ext/dhtmlxgrid_pgn.js');
echo link_tag('dhtmlx/dhtmlxGrid/codebase/ext/dhtmlxgrid_pgn_bricks.css');
echo link_tag('dhtmlx/dhtmlxWindows/codebase/dhtmlxwindows.css');
echo link_tag('dhtmlx/dhtmlxWindows/codebase/skins/dhtmlxwindows_dhx_web.css');
echo script_tag('dhtmlx/dhtmlxWindows/codebase/dhtmlxcontainer.js');
?>
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">List Users</div>
<div class="panel-body">
<div id="mygrid_container" style="width:100%; clear:both;"></div>
<div id="forPaging">
<span id="pagingArea"></span>
<span id="infoArea"></span>
</div>
<div id="UIBlocker"><img src="<?php echo base_url('images/loading.gif'); ?>" /></div>
</div>
</div>
</div>
</div>