EasyUI Forum
April 30, 2024, 09:17:15 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Dynamically filling an editable combo box  (Read 8105 times)
AJLX
Newbie
*
Posts: 17


View Profile
« on: August 22, 2016, 09:49:44 AM »

Hey guys,

I have the following code to create a combo box:
Code:
<th field="spot" width="10%" align="center" sortable="true" editor="text">Spot #</th>
<th field="fixture_id" width="20%" sortable="true">Fixture ID</th>
<th field="mode_id" width="10%" align="right" editor:{
type:'combobox',
options:{
url:'mode_id_select.php',
valueField:'fixture_id',
required:true
}
}
}, >Mode</th>
<th field="dmx_univ" width="10%" align="right" sortable="true" editor="text">Universe</th>


And the following PHP file:
Code:
<?php 
require ('../Inx/mysqli_project.php');
$items = array();
$fixture_id = isset($_POST['fixture_id'])
$sql "SELECT mode_id FROM fixture_details WHERE fixture_id = '$fixture_id'";
$result $con->query($sql);

if (
$result->num_rows 0)
{
// output data of each row
while($row $result->fetch_assoc())
array_push($items$row);

}

echo json_encode($items);
?>


Basically to run the SQL statement I need to use the fixture_id value from the same row. So somehow I need to send that across to the PHP file. Can someone help me with doing this please?

Thanks,

Andy
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: August 23, 2016, 02:43:09 AM »

Set the request parameter before loading data from remote server. Please try this code.
Code:
editor:{
type:'combobox',
options:{
//...,
onBeforeLoad:function(param){
var index = $(this).closest('tr.datagrid-row').attr('datagrid-row-index');
var row = $('#dg').datagrid('getRows')[index];
param.fixture_id = row.fixture_id;
}
}
}
Logged
AJLX
Newbie
*
Posts: 17


View Profile
« Reply #2 on: September 10, 2016, 03:38:48 AM »

Hey,


Thanks for taking the time to reply, I managed to get side tracked with other projects.

 I now have this:
Code:
<th field="mode_id" width="10%" align="right" 	editor:{
type:'combobox',
options:{
url:'mode_id_select.php',
valueField:'fixture_id',
required:true

onBeforeLoad:function(param){
var index = $(this).closest('tr.datagrid-row').attr('datagrid-row-index');
var row = $('#dg').datagrid('getRows')[index];
param.fixture_id = row.fixture_id;
}
}
}, >Mode</th>

And it still isn't working? Any ideas please?
Logged
iklotzko
Newbie
*
Posts: 15


View Profile Email
« Reply #3 on: September 13, 2016, 06:57:22 AM »

Hi AJ,

I assume this is used in datagrid as one of the editors. The issue of course here is specifying the url: mode_id_select.php?figure_id=<row-value-for-fid>

Use the onBeforeEdit method to configure the editor before it is shown. Within that event try this

var ed = $('grid-selector').datagrid('getEditor', {index:<row-index>,field:'<combo-field-name>'});
$(ed.target).combobox('options')['url'] = 'mode_id_select.php?figure_id=<row-value-for-fid>';

You can also use the queryParams property and leave the url alone. It sure would be nice if jeasy provided a callback/event to dynamically retrieve the url or query params.

Hope this works for you,

Ira
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!