将行号列添加到 jquery 数据表 [英] Add row number column to jquery datatables

查看:17
本文介绍了将行号列添加到 jquery 数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望 jQuery 数据表像 VB 中的 datagrid 一样在第一列中自动创建行号列.

I want jQuery datatables to automatically create row number column in the first column like datagrid in VB.

看起来像这样:

有人知道怎么做吗?

推荐答案

您只需在 aoColumns 中定义一个空列.

You just define an empty column in aoColumns.

然后在 fnRowCallback 函数中,您只需编辑您喜欢的列.每次创建新行时都会运行此回调.

Then in fnRowCallback function you just edit the column how you like. This callback is run every time new row is created.

基本上,如果您的第一列有行号,您可以在 fnRowCallback 中执行此操作:

Basicly if your first column has the row number, you could just do this in fnRowCallback:

var index = iDisplayIndex +1;
$('td:eq(0)',nRow).html(index);
return nRow;

这篇关于将行号列添加到 jquery 数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆