dongluzhi5208
2017-07-20 20:05
浏览 31
已采纳

如何让数据表在codeigniter中显示大写

I can't figure how to get data table to show the letters uppercase in the table. I need name and vendor to be upper case. I did add the onblur="this.value=this.value.toUpperCase()" to the add form but when I hit submit the table shows the data in all lowercase. So I figured I could force the data tables to show it in uppercase. I posted partial code from my controller. Any helped would be appreciated.

public function ajax_list()
    {
        $list = $this->visitor_log_list->get_datatables();
        $data = array();
        $no = $_POST['start'];
        foreach ($list as $visitor_log_list) {
            $no++;
            $row = array();
            $row[] = $visitor_log_list->date;
            $row[] = $visitor_log_list->name;
            $row[] = $visitor_log_list->vendor;
            $row[] = $visitor_log_list->department;
            $row[] = $visitor_log_list->contact_person;
            $row[] = $visitor_log_list->expected_arrival_time;

            //add html for action
            $row[] = '<a class="btn btn-sm btn-link " href="javascript:void()" title="Edit" onclick="edit_visitor_log('."'".$visitor_log_list->id."'".')"><i class="glyphicon glyphicon-pencil"></i> Edit</a>
                  <a class="btn btn-sm text-warning" href="javascript:void()" title="Hapus" onclick="delete_visitor_log('."'".$visitor_log_list->id."'".')"><i class="glyphicon glyphicon-trash"></i> Delete</a>';

            $data[] = $row;
        }

        $output = array(
                        "draw" => $_POST['draw'],
                        "recordsTotal" => $this->visitor_log_list->count_all(),
                        "recordsFiltered" => $this->visitor_log_list->count_filtered(),
                        "data" => $data,
                );
        //output to json format
        echo json_encode($output);
    }

图片转代码服务由CSDN问答提供 功能建议

我无法想象如何获取数据表以在表格中显示大写字母。 我需要名字和供应商是大写的。 我确实将 onblur =“this.value = this.value.toUpperCase()”添加到添加表单中,但是当我点击提交时,表格显示全部小写的数据。 所以我想我可以强制数据表以大写形式显示它。 我从我的控制器发布了部分代码。 任何帮助将不胜感激。

  public function ajax_list()
 {
 $ list = $ this-&gt; visitor_log_list-&gt; get_datatables(); 
 $ data  = array(); 
 $ no = $ _POST ['start']; 
 foreach($ list as $ visitor_log_list){
 $ no ++; 
 $ row = array(); 
 $ row [] =  $ visitor_log_list-&gt; date; 
 $ row [] = $ visitor_log_list-&gt; name; 
 $ row [] = $ visitor_log_list-&gt; vendor; 
 $ row [] = $ visitor_log_list-&gt; department; \  n $ row [] = $ visitor_log_list-&gt; contact_person; 
 $ row [] = $ visitor_log_list-&gt; expected_arrival_time; 
 
 //为动作添加html 
 $ row [] ='&lt; a class =  “btn btn-sm btn-link”href =“javascript:void()”title =“Edit”onclick =“edit_visitor_log('。”'“。$ visitor_log_list-&gt; id。”'“。')”&gt;  &lt; i class =“glyphicon glyphicon-pencil”&gt;&lt; / i&gt; 编辑&lt; / a&gt; 
&lt; a class =“btn btn-sm text-warning”href =“javascript:void()”title =“Hapus”onclick =“delete_visitor_log('。”'“。$ visitor_log_list-&gt  ; id。“'”。')“&gt;&lt; i class =”glyphicon glyphicon-trash“&gt;&lt; / i&gt; 删除&lt; / a&gt;'; 
 
 $ data [] = $ row; 
} 
 
 $ output = array(
“draw”=&gt; $ _POST ['draw'],
“  recordsTotal“=&gt; $ this-&gt; visitor_log_list-&gt; count_all(),
”recordsFiltered“=&gt; $ this-&gt; visitor_log_list-&gt; count_filtered(),
”data“=&gt; $ data,  
); 
 //输出为json格式
 echo json_encode($ output); 
} 
   
 
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doumo3903 2017-07-20 20:08
    已采纳

    Just wrap the strings in strtoupper():

    <?php
        public function ajax_list() {
            $list = $this->visitor_log_list->get_datatables();
            $data = array();
            $no   = $_POST['start'];
            foreach ($list as $visitor_log_list) {
                $no++;
                $row    = array();
                $row[]  = $visitor_log_list->date;
                $row[]  = strtoupper($visitor_log_list->name);
                $row[]  = strtoupper($visitor_log_list->vendor);
                $row[]  = $visitor_log_list->department;
                $row[]  = $visitor_log_list->contact_person;
                $row[]  = $visitor_log_list->expected_arrival_time;
                //add html for action
                $row[]  = '<a class="btn btn-sm btn-link " href="javascript:void()" title="Edit" onclick="edit_visitor_log(' . "'" . $visitor_log_list->id . "'" . ')"><i class="glyphicon glyphicon-pencil"></i> Edit</a>
                      <a class="btn btn-sm text-warning" href="javascript:void()" title="Hapus" onclick="delete_visitor_log(' . "'" . $visitor_log_list->id . "'" . ')"><i class="glyphicon glyphicon-trash"></i> Delete</a>';
                $data[] = $row;
            }
            $output = array(
                "draw" => $_POST['draw'],
                "recordsTotal" => $this->visitor_log_list->count_all(),
                "recordsFiltered" => $this->visitor_log_list->count_filtered(),
                "data" => $data
            );
            //output to json format
            echo json_encode($output);
        }
    ?>
    
    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题