【问题标题】:Jquery DataTable with Ignited-Datatables CodeIgniter issue带有 Ignited-Datatables CodeIgniter 问题的 Jquery DataTable
【发布时间】:2013-12-01 16:38:36
【问题描述】:

嗨朋友们,我正在使用它对我有用的 codeigniter 数据表,但我遇到了一些问题。

table name: employe 

emp_no emp_name emp_type etc.........

100    x        0
101    y        1
102    z        1
103    p        0

上表工作正常,但 emp_type 列 0 替换为非永久,1 替换为永久

具有 0,1 个值的数据库 0=非永久 emp 1=永久 emp

如何解决这个问题

注意:不要告诉我存储数据库永久或非永久值 像

<input type="radio" name"emp_typ" value="Permanent">Yes
<input type="radio" name"emp_typ" value="not Permanent">No

我正在排序,我需要下面的方式

  <input type="radio" name"emp_typ" value="1">Yes
    <input type="radio" name"emp_typ" value="0">No

【问题讨论】:

  • 那么你的表格渲染代码在哪里?如果是我,模型会添加额外的字段,并告诉数据表要显示哪一列以及要过滤/排序的列
  • sorry add_column() 可用于我已经实现了编辑和删除功能。我想要 0,1 值问题老板
  • 我知道你想要什么...你的代码呢?
  • $(document).ready(function() { $('#example').dataTable( { "bProcessing": true, "bServerSide": true, "sAjaxSource": "scripts/server_processing .php" } ); } );
  • 您是否尝试过我的建议,即在您从 db get 之后并在转换为 json 之前添加新字段?

标签: jquery codeigniter datatable


【解决方案1】:

创建一个辅助函数get_type来改变数据

function get_type($type)
{
  if($type == 0) return 'Not Permanent';
  if($type == 1) return 'Permanent';
}

然后你可以使用带有edit_column的helper来改变数据

$this->datatables->edit_column('Type', '$1','get_type(emp_type)');

确保在 edit_column 中调用 get_type 之前加载帮助程序。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-05-06
    • 2016-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多