EasyUI Forum
April 26, 2024, 03:07:35 PM *
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 PROBLEM DISPLAY VALUE/TEXT (Loaded Values are OK)  (Read 6241 times)
rannacher
Jr. Member
**
Posts: 52


View Profile
« on: July 27, 2015, 03:11:37 AM »

Please help, I dont get the combobox to display the selected value correctly.
See attached screenshot!
When open all is fine, but the moment you select a value it has the special chars again.

And thats regardless of what I do in the combobox

                    <th data-options="field:'projectid',width:225,
                            formatter:function(value,row){
                                var projectnamedecoded = mrrdecode(row.projectname);
                                row.projectname = projectnamedecoded;
                                //alert('formatter\n value=['+ value +']\n row='+ JSON.stringify(row) +']\n row.projectname='+row.projectname+']');
                                return row.projectname;   
                            },
                            editor:{
                                type:'combobox',
                                options:{                                                                                           
                                    valueField:'projectid',
                                    textField:'projectname',
                                    method:'get',
                                    url:'http://www.rannacher.com/_subdomain/engineers4you/includes/BO/load_existing_projects.php?mandant=HHMZT',
                                    required:true,
                                    onSelect: function(row){
                                        var projectnamedecoded = mrrdecode(row.projectname);
                                        row.projectname = projectnamedecoded;
                                        //$(this).combobox('setValue', row.projectname );
                                        return row;
                                    },
                                    onChange: function(row)
                                    {
                                      //alert('onChange Combo'+row);
                                    }
                                }
                            }">Projekt</th>

Please help me. Thx in advance!
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: July 27, 2015, 07:00:38 PM »

Here is the data returned from your URL.
Code:
[{"ID":"2050","NAME":"15001-Universumstrasse 48","projectid":"2050","projectname":"15001-Universumstrasse&#32;48"},{"ID":"2051","NAME":null,"projectid":"2051","projectname":"15002-Diverse&#32;Gesch&#228;ftsf&#228;lle"}]

Please modify your 'load_existing_projects.php' to return the correct data. Another way to solve this issue is to use the 'loadFilter' function to convert your data to the correct format.
Code:
editor:{
    type:'combobox',
    options:{                                                                                           
        valueField:'projectid',
        textField:'projectname',
        method:'get',
        url:'http://www.rannacher.com/_subdomain/engineers4you/includes/BO/load_existing_projects.php?mandant=HHMZT',
loadFilter: function(data){
var tmp = $('<span></span>');
var rows = $.map(data, function(item){
tmp.html(item.projectname);
item.projectname = tmp.text();
return item;
});
tmp.remove();
return rows;
}
    }
}
Logged
rannacher
Jr. Member
**
Posts: 52


View Profile
« Reply #2 on: July 28, 2015, 03:08:25 AM »

FIRST OF ALL - Your loadFilter WORKS like a charm, THX A LOT!


Just for better understanding and consequent future use to avoid problems:

I tried your first proposed solution and actually my data gets masked on php side.
If I dont mask it then it is not displayed at all in combobox - appearance then is a smaller sized blanc row when opening the combobox (u may try "Geschäftsfälle").
For that I use :

Code (sorry dont know how to insert elegantly like your tagged code):
       
        //PHP Code:
        while($row = mysqli_fetch_assoc($result))
        {
            $row['projectid']=      $row['ID'];
            $row['projectname']=    umlaute($row['NAME']);
            $row_set[] = $row;
        }
     
       function umlaute($text)
      {
          $returnvalue="";
          for($i=0;$i<strlen($text);$i++){
              $teil=hexdec(rawurlencode(substr($text, $i, 1)));
              if($teil<32||$teil>1114111){
                  $returnvalue.=substr($text, $i, 1);
              }else{
                  $returnvalue.="&#".$teil.";";
              }
          }
          return $returnvalue;
      }

      // client/javascript - I use for decoding - which works fine but I just DID NOT COMBINE IT WITH LOADFILTER
      function mrrdecode(str)
      {
        var dummy = document.createElement('textarea');
        dummy.innerHTML = str;
        return dummy.value;         
      }


Accordingly if I open the url stated url:'http://www.rannacher.com/_subdomain/engineers4you/includes/BO/load_existing_projects.php?mandant=HHMZT'
I DONT get any of these special chars, like you printed. FFirst things I tested when debugging. Not in chrome not in IE etc.Huh
Any idea?
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!