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);
    }
  • 写回答

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);
        }
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?