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

报告相同问题?

悬赏问题

  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集
  • ¥15 在启动roslaunch时出现如下问题
  • ¥15 汇编语言实现加减法计算器的功能
  • ¥20 关于多单片机模块化的一些问题
  • ¥30 seata使用出现报错,其他服务找不到seata
  • ¥35 引用csv数据文件(4列1800行),通过高斯-赛德尔法拟合曲线,在选取(每五十点取1点)数据,求该数据点的曲率中心。
  • ¥20 程序只发送0X01,串口助手显示不正确,配置看了没有问题115200-8-1-no,如何解决?
  • ¥15 Google speech command 数据集获取
  • ¥15 vue3+element-plus页面崩溃