EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: x3no on August 22, 2013, 06:14:01 AM



Title: [Solved] Display text in propertygrid remote combobox
Post by: x3no 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.

 


Title: Re: Display text in propertygrid remote combobox
Post by: stworthy 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"}
]
}
}}


Title: Re: Display text in propertygrid remote combobox
Post by: x3no 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.


Title: Re: Display text in propertygrid remote combobox
Post by: stworthy on August 23, 2013, 12:45:50 AM
Providing some code snippets will describe your issue more clearly.


Title: Re: Display text in propertygrid remote combobox
Post by: mephisto 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.


Title: Re: Display text in propertygrid remote combobox
Post by: stworthy 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


Title: Re: Display text in propertygrid remote combobox
Post by: mephisto 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.


Title: Re: Display text in propertygrid remote combobox
Post by: stworthy 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/


Title: Re: [Solved] Display text in propertygrid remote combobox
Post by: x3no on August 26, 2013, 12:46:11 PM
This is exactly the solution I was looking for.

Thanks for all the help.


Title: Re: [Solved] Display text in propertygrid remote combobox
Post by: mephisto 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 (http://www.jeasyui.com/forum/index.php?topic=2147.0)