I have a Grid with 4 columns. 2nd Colum is of type Combo.
When adding a new row, i am able to integrate Combo box successfully within the Grid (see code below)
dhxGrid.setColTypes("ed,combo,ed,ed");
combo = dhxGrid.getColumnCombo(1);
combo.loadXML("xml/data.xml");
dhxGrid.addRow((new Date()).valueOf(),[0,'Select Value ...','-1','-1'],dhxGrid.getRowIndex(dhxGrid.getSelectedId()));
Contents of data.xml file:
<?xml version="1.0" ?>
<complete>
<option value="1">!one</option>
<option value="2">!two</option>
<option value="3">!three</option>
<option value="4">!four</option>
<option value="5">!five</option>
<option value="6">!six</option>
<option value="7">!seven</option>
<option value="8">!eight</option>
<option value="9">!nine</option>
<option value="10">!ten</option>
</complete>
However, i get the message “Undefined Index: mask” when i try to do the same using a php file.
Below is the code:
dhxGrid.setColTypes("ed,combo,ed,ed");
combo = dhxGrid.getColumnCombo(1);
combo.loadXML("php/data.php");
dhxGrid.addRow((new Date()).valueOf(),[0,'Select Value ...','-1','-1'],dhxGrid.getRowIndex(dhxGrid.getSelectedId()));
The contents of data.php file are:
[code]<?php
header(“Content-type:text/xml”);
ini_set(‘max_execution_time’, 7000);
require_once(‘php/config.php’);
print("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
$link = mysql_pconnect($mysql_host, $mysql_user, $mysql_pasw);
$db = mysql_select_db ($mysql_db);
if (!isset($_GET["pos"])) $_GET["pos"]=0;
$sql = "Select * from RandomWords";
$res = mysql_query ($sql);
getDataFromDB($_GET["mask"]);
mysql_close($link);
function getDataFromDB($mask){
$sql = "SELECT DISTINCT item_nm FROM RandomWords Where item_nm like '".mysql_real_escape_string($mask)."%'";
$sql.= " Order By item_nm LIMIT ". $_GET["pos"].",100";
if ( $_GET["pos"]==0)
print("<complete>");
else
print("<complete add='true'>");
$res = mysql_query ($sql);
if($res){
while($row=mysql_fetch_array($res)){
print("<option value=\"".$row["item_nm"]."\">");
print($row["item_nm"]);
print("</option>");
}
}else{
echo mysql_errno().": ".mysql_error()." at ".__LINE__." line in ".__FILE__." file<br>";
}
print("</complete>");
}
?>[/code]
How can i get this functionality to work? In this case, i have to get the data for the combo box dynamically from a mySQL table. Thanks in advance.