EasyUI Forum
May 18, 2024, 11:28:22 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: [SOLVED] how to show character space on easyui-datagrid  (Read 7636 times)
sky_proj
Newbie
*
Posts: 24


View Profile
« on: April 25, 2016, 02:00:03 AM »

source table mysql : people
CODE |  NAME
A1     | AGUS       => with 0 space
A2     | A GUS      => with 1 space
A3     | A  GUS     => with 2 space
A4     | A   GUS
A5     | A    GUS
A6     | A    GUS

file : getdata.php
// total rec data
$rs = mysql_query("select count(*) from people");
$result["total"] = mysql_result($rs,0);

// get detail data
$query="select * from people";
$rs = mysql_query($query) or die(mysql_error());

//get into format json
$items = array();
while($row = mysql_fetch_object($rs)){
   array_push($items, $row);
}
//total keseluruhan isi data
$result["rows"] = $items;
echo json_encode($result);

data.php
<table id="serie" title="Browse" class="easyui-datagrid" style="width:400px;height:250px"        data-options="url:'getdata.php',fitColumns:true,singleSelect:true">>  
  <thead>  
  <tr>
     <th field="CODE" width="100">CODE</th>  
     <th field="NAME" width="100">NAME</th>  
  </tr>  
  </thead>  
</table>

result datagrid :
CODE |  NAME
A1     | AGUS      => with 1 space
A2     | AGUS      => with 1 space
A3     | AGUS      => with 1 space
A4     | AGUS      => with 1 space
A5     | AGUS      => with 1 space
A6     | AGUS      => with 1 space

any one can help me i want show like source :
A1     | AGUS       => with 0 space
A2     | A GUS      => with 1 space
A3     | A  GUS     => with 2 space
A4     | A   GUS    => with 3 space
A5     | A    GUS   => with 4 space
A6     | A    GUS   => with 5 space

Thanks
« Last Edit: April 25, 2016, 05:56:42 PM by sky_proj » Logged
Pierre
Sr. Member
****
Posts: 439


View Profile Email
« Reply #1 on: April 25, 2016, 03:27:39 AM »

Try to add this
Code:
  &nbsp;
before "GUS"
Logged
Max Lamda
Newbie
*
Posts: 48


View Profile
« Reply #2 on: April 25, 2016, 04:24:08 AM »

Just replace the spaces in the field "NAME" by a non-breaking space (=&nbsp;) as mentioned above but also by any other character(s) for your choice.

while($row = mysql_fetch_object($rs)){
   array_push($items, $row);
}

becomes

while($row = mysql_fetch_object($rs)){
  $row['NAME']=str_replace(' ', '&nbsp;', $row['name']);
   array_push($items, $row);
}

Logged
sky_proj
Newbie
*
Posts: 24


View Profile
« Reply #3 on: April 25, 2016, 05:46:47 PM »

Just replace the spaces in the field "NAME" by a non-breaking space (=&nbsp;) as mentioned above but also by any other character(s) for your choice.

while($row = mysql_fetch_object($rs)){
   array_push($items, $row);
}

becomes

while($row = mysql_fetch_object($rs)){
  $row['NAME']=str_replace(' ', '&nbsp;', $row['name']);
   array_push($items, $row);
}



it's working.. thanks a lot
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!