EasyUI Forum
June 16, 2024, 03:36:58 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: Combobox Data by Value Condition  (Read 5334 times)
comuda
Newbie
*
Posts: 3


View Profile
« 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.
« Last Edit: July 12, 2015, 08:00:57 PM by comuda » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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',...);
« Last Edit: July 13, 2015, 02:18:12 AM by stworthy » Logged
comuda
Newbie
*
Posts: 3


View Profile
« Reply #2 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 ?
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!