EasyUI Forum
May 16, 2024, 04:02:18 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: [Solved] Display text in propertygrid remote combobox  (Read 22764 times)
x3no
Newbie
*
Posts: 5


View Profile Email
« on: August 22, 2013, 06:14:01 AM »

Rephrasing my previous post:

Whats the best way to get a remotely populated propertygrid row combobox to display text instead of value?
The combobox editor object and row has only value and when remotely populated does not even have a data array, so using a formatter like in Row Editing in DataGrid demo does not seem be the way to go.

 
« Last Edit: August 26, 2013, 12:43:03 PM by x3no » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: August 22, 2013, 06:49:49 PM »

Is it possible to set 'valueField' and 'textField' properties to the same text field in combobox data, just like this:
Code:
	{"name":"SSN","value":"c2","group":"ID Settings","editor":{
"type":"combobox",
"options":{
"valueField":"text",
"textField":"text",
"data":[
{"id":1,"text":"c1"},
{"id":2,"text":"c2"},
{"id":3,"text":"c3"}
]
}
}}
Logged
x3no
Newbie
*
Posts: 5


View Profile Email
« Reply #2 on: August 23, 2013, 12:11:59 AM »

Thanks for your reply. Unfortunately I still need to send combobox value to server on submit. So
Value should be kept while text is displayed.
In short here's what happens:
Property grid is created with remotely passed json object containing combobox editor with
numeric id value and url that will provide the same numeric id and text definition for it.
When combobox row is focused the text is shown as expected, but in other cases user is presented by a meaningless id number, which however is the one that should be fed to the server on submit.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: August 23, 2013, 12:45:50 AM »

Providing some code snippets will describe your issue more clearly.
Logged
mephisto
Newbie
*
Posts: 8


View Profile
« Reply #4 on: August 24, 2013, 11:51:33 AM »

Same problem here.
I've two chain combobox in edatagrid.
I need to use, for each combobox, different valueField and textField to chain them and relate data in DB (I pass $prov=valueField variable in php to populate second combobox).
When I edit a combobox it's all ok, but when I deselect the row I see the valueField in cell, not the textField.
Here is the code:
Code:
columns:[[
{field:'provincia',title:'Provincia',width:400,
editor:{
type:'combobox',
options:{
url:'combobox_provincia.php',
valueField:'idprovincia',
textField:'siglaprovincia',
onChange:function(value){
var index = $(this).closest('tr.datagrid-row').attr('datagrid-row-index');
var ed = $('#tt').edatagrid('getEditor',{index:index,field:'comune'});
$(ed.target).combobox('reload','combobox_comuninew.php?prov='+value);
alert(value);
}
}
}
},
{field:'comune',title:'Comune',width:400,
editor:{
type:'combobox',
options:{
valueField:'idcomune',
textField:'nomecomune'
}
}
}
]]


I suppose I have to use formatter function for both columns but I don't understand how to implement the function with my code that uses edatagrid.
« Last Edit: August 24, 2013, 12:32:15 PM by mephisto » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #5 on: August 25, 2013, 12:15:24 AM »

Please refer to this example to learn the usage of formatter.
http://www.jeasyui.com/demo/main/index.php?plugin=DataGrid&theme=default&dir=ltr&pitem=Row%20Editing%20in%20DataGrid
Logged
mephisto
Newbie
*
Posts: 8


View Profile
« Reply #6 on: August 25, 2013, 05:36:18 AM »

Already tried to add
Code:
formatter:function(value,row){
return row.here_the_name_of_textField_of_the_field;
},
in both fields (provincia and comune).
For what I've understood from the example linked I've also to write a "function endEditing" that I don't know how to trig and however is totally out of my abilities.

What I don't understand is why the control must have a similar default behavior especially considering the control already record a valueField and a textField. I supposed that valueField was machine useful to interact with DB, textField for human readability.

However at the time I'm stuck on the problem.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #7 on: August 25, 2013, 05:33:27 PM »

Please refer to this example to learn how to use 'formatter' in editable datagrid.
http://jsfiddle.net/hrvKP/
Logged
x3no
Newbie
*
Posts: 5


View Profile Email
« Reply #8 on: August 26, 2013, 12:46:11 PM »

This is exactly the solution I was looking for.

Thanks for all the help.
Logged
mephisto
Newbie
*
Posts: 8


View Profile
« Reply #9 on: September 01, 2013, 08:13:51 AM »

Cannot find a solution to my problem, also trying to implement your example.
I've opened another discussion about the same argument here:

http://www.jeasyui.com/forum/index.php?topic=2147.0
« Last Edit: September 02, 2013, 02:24:23 AM by mephisto » 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!