use _fnAjaxUpdateDraw ( oSettings, lastDataSet ) refresh datatable outside

use _fnAjaxUpdateDraw ( oSettings, lastDataSet ) refresh datatable outside

MackMack Posts: 3Questions: 0Answers: 0
edited August 2012 in DataTables 1.9
hi,i am a chinese,my english is poorest.
I have an problem when I use _fnAjaxUpdateDraw(Settings, json) load datas from server via ajax. It occured a fatal error!
so, can anybody need you helps;
can you?

This is my scirpt code is below:
[code]<%@ page language="java" pageEncoding="utf-8"%>
<%@ include file="/common/taglib.jsp"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">




My JSP 'index.jsp' starting page




@import "common/css/demo_table.css";

@import "common/css/demo_page.css";







var oTable;
var uri="ms/user!list.action?dd="+new Date().getTime();
$(function() {

oTable = $("#example").dataTable(
{
"bProcessing" : true,
"bServerSide" : true,//使用服务端数据
"sPaginationType" : "full_numbers",//分页样式,完整样式
"sAjaxSource" : uri,
"bLengthChange": true,
"bFilter": true,//禁用搜索栏
"bAutoWidth": true,//自动调整宽度
"bStateSave": true,//保存状态到cookie *************** 很重要 , 当搜索的时候页面一刷新会导致搜索的消失。使用这个属性就可避免了
"oLanguage" : {
"sLoadingRecords" : "正在加载数据,请稍等...",
"sProcessing" : "正在处理...",
"sLengthMenu" : "每页 _MENU_ 行",
"sZeroRecords" : "没有找到记录",
"sEmptyTable" : "没有找到记录",
"sInfo" : "当前显示从 _START_ 到 _END_ ,总记录数: _TOTAL_",
"sInfoFiltered" : "(总共 _MAX_ 记录)",
"sInfoEmpty" : "",
"sSearch" : "搜索",
"oPaginate" : {
"sFirst" : "首页",
"sPrevious" : "前页",
"sNext" : "下页",
"sLast" : "尾页"
}
}
});

// oTable.fnFilter( 'test string' );

//点击的时候,显示被点击的记录处于选中状态
$("#example").click(function(event) {
$(oTable.fnSettings().aoData).each(function() {
$(this.nTr).removeClass('row_selected');
});
$(event.target.parentNode).addClass('row_selected');
});
});


function loadPages(){
var username=$("#us").val();
var email=$("#em").val();
var phone=$("#mn").val();

if(username){
uri+="&username="+username;
}

if(email){
uri+="&email="+email;
}

if(phone){
uri+="&phone="+phone;
}

oTable.fnDraw();
/* $.ajax({
type: "POST",
url: "ms/user!list.action?dd="+new Date().getTime(),
data: {"username":username},
success: function(msg){
oTable._fnAjaxUpdateDraw(oTable.fnoSettings,msg);
}
}); */
}

function addUser() {

var anSelected = fnGetSelected(oTable);

if (anSelected.length == 0) {
alert("请选中您要添加登录帐号的人员!");
return;
}
//获得被选中记录的ID
var personId = anSelected[0].children[0].innerHTML;

window.location = "system/user!addInput.action?person.id=" + personId;
}

function updateUser() {
var anSelected = fnGetSelected(oTable);

if (anSelected.length == 0) {
alert("请选中您要更新帐号的人员!");
return;
}
//获得被选中记录的ID
var personId = anSelected[0].children[0].innerHTML;

window.location = "system/user!updateInput.action?id=" + personId;
}

function deleteUser() {

var anSelected = fnGetSelected(oTable);

if (anSelected.length == 0) {
alert("请选中您要删除其帐号的人员!");
return;
}

if (!confirm("请确认是否要删除选中人员的登录帐号,删除之后,此人员将无法登录系统!")) {
return;
}

//获得被选中记录的ID
var personId = anSelected[0].children[0].innerHTML;
$.get("system/user!del.action?id=" + personId, function() {
oTable.fnDeleteRow(anSelected[0]);
});
}

function fnGetSelected(oTableLocal) {
var aReturn = new Array();
var aTrs = oTableLocal.fnGetNodes();

for ( var i = 0; i < aTrs.length; i++) {
if ($(aTrs[i]).hasClass('row_selected')) {
aReturn.push(aTrs[i]);
}
}
return aReturn;
}

function fnAlert() {
alert($("#inp").val());
alert($("#sSearch").val());
alert($("#oSearch").val());
alert($("#oPreviousSearch").val());
}




用户名:

邮箱:

手机号:

昵称:








ID



姓名



昵称



电话



邮箱



状态



创建时间










[/code]

I need 4 conditons to query.
invoke loadPages() when i click a query button but it alert "oSettings undefined";

can anybody give me a example. I want to Hand to request server for query!In fact,the uri although I changed the value, but it did not change.

Now I want to request server with params and redraw datatable when accepte json datas from server;

Can anybody help me?

Forgive my English is very poor!
Thanks very much!

Replies

  • MackMack Posts: 3Questions: 0Answers: 0
    if I use like this

    [code]$.ajax({
    type: "POST",
    url: "ms/user!list.action?dd="+new Date().getTime(),
    data: {"username":username},
    success: function(msg){
    oTable._fnAjaxUpdateDraw(oTable.fnSettings(),msg);
    }
    }); [/code]

    IE alert SCRIPT5007: 无法获取属性“length”的值: 对象为 null 或未定义
    jquery.dataTables.min.js, 行49 字符324!

    Can anybody help me?
This discussion has been closed.