EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: comuda on July 12, 2015, 07:33:17 PM



Title: Combobox Data by Value Condition
Post by: comuda on July 12, 2015, 07:33:17 PM
Hello everyone,

i need help to solve my problem about combobox data (inline editing).
First, i'm sorry if i write bad english.

The case,
I have edatagrid (inline editing) like this :

Code:
<th field="pipeline_status" width="50" editor="{type:'combobox',options:{required:true,data:products,textField:'name',valueField:'productid'}}" formatter="status" align="left">Status</th>

I have some record from mysql table :
1. PROCESS
2. SOLISIT
3. DOCUMENT
4. NAP
5. etc

In the combobox, if the current value is SOLISIT, combobox data only show > 2 (Document, NAP, etc), and hide the value < 2 (Process).
There is no problem in mysql query, because i just limit query to get it.

I'm doing this script :

Code:
var products = <?php echo $status?> ; //mysql query limit 1,5
var products2 = <?php echo $status2?> ; // mysql query limit 2,5

function status(value){
if (value < 2){

for(var i=0; i<products.length; i++){
if (products[i].productid == value) return products[i].name;
}
return value;
}
else if (value >= 2){

for(var i=0; i<products2.length; i++){
if (products2[i].productid == value) return products2[i].name;
}
return value;
}
}

But, the combobox data show all of data, and i think because of default command (data:products):

Code:
<th field="pipeline_status" width="50" editor="{type:'combobox',options:{required:true,data:products,textField:'name',valueField:'productid'}}" formatter="status" align="left">Status</th>


So, how can i solve this ? Can somebody help me? Sworthy, maybe?
Here i'm using CodeIgniter Framework.


Title: Re: Combobox Data by Value Condition
Post by: stworthy on July 13, 2015, 02:16:30 AM
To hide a combobox item, get that item element and then call .hide() method to hide it. The code below shows how to achieve this functionality.
Code:
<th field="pipeline_status" width="50" data-options="
editor: {
type:'combobox',
options:{
//...
onShowPanel:function(){
var el = $(this).combobox('options').finder.getEl(this, '1');
el.hide();
}
}
}
">Status</th>

Another simple way to solve this issue is to call 'loadData' method to load another dataset.
Code:
$(...).combobox('loadData',...);


Title: Re: Combobox Data by Value Condition
Post by: comuda on July 26, 2015, 11:29:32 PM
To hide a combobox item, get that item element and then call .hide() method to hide it. The code below shows how to achieve this functionality.
Code:
<th field="pipeline_status" width="50" data-options="
editor: {
type:'combobox',
options:{
//...
onShowPanel:function(){
var el = $(this).combobox('options').finder.getEl(this, '1');
el.hide();
}
}
}
">Status</th>

Another simple way to solve this issue is to call 'loadData' method to load another dataset.
Code:
$(...).combobox('loadData',...);


Thank for your response sworthy,
But it's not the answer.

I mean,
if the current value is 2 (Solisit), the combobox only show next record (Document, Nap, etc)
if the current value is 3 (Document), the combobox only show next record (Nap, etc),

How can i do that ?