我发送ajax数据表服务器端请求 它获取所有值并显示。但是显示格式不正确。即使我尝试搜索结果,它也会显示所有记录,但发送请求没有任何反应,但是再次获取所有记录意味着搜索无法执行,并且过滤也不起作用。
当我打开Chrome网络调试时,我看到ajax请求发送了Draw 1,2,3等,但是作为响应, 平局总是0不变。 我尝试了很多事情,还正确地包含了数据表
我正在使用laravel 5.2 Datatable 1.0.10 包括yajra文件 添加laravel提供和别名 它显示所有结果,但不进行分页,甚至不进行过滤和搜索
** Laravel刀片文件**
class DagRun(Base, LoggingMixin):
"""
DagRun describes an instance of a Dag. It can be created
by the scheduler (for regular runs) or by an external trigger
"""
__tablename__ = "dag_run"
ID_PREFIX = 'scheduled__'
ID_FORMAT_PREFIX = ID_PREFIX + '{0}'
id = Column(Integer, primary_key=True)
dag_id = Column(String(ID_LEN))
execution_date = Column(UtcDateTime, default=timezone.utcnow)
start_date = Column(UtcDateTime, default=timezone.utcnow)
end_date = Column(UtcDateTime)
_state = Column('state', String(50), default=State.RUNNING)
run_id = Column(String(ID_LEN))
external_trigger = Column(Boolean, default=True)
conf = Column(PickleType)
dag = None
__table_args__ = (
Index('dag_id_state', dag_id, _state),
UniqueConstraint('dag_id', 'execution_date'),
UniqueConstraint('dag_id', 'run_id'),
)
class TaskInstance(Base, LoggingMixin):
__tablename__ = "task_instance"
task_id = Column(String(ID_LEN), primary_key=True)
dag_id = Column(String(ID_LEN), primary_key=True)
execution_date = Column(UtcDateTime, primary_key=True)
start_date = Column(UtcDateTime)
end_date = Column(UtcDateTime)
duration = Column(Float)
state = Column(String(20))
_try_number = Column('try_number', Integer, default=0)
max_tries = Column(Integer)
hostname = Column(String(1000))
unixname = Column(String(1000))
job_id = Column(Integer)
pool = Column(String(50))
queue = Column(String(50))
priority_weight = Column(Integer)
operator = Column(String(1000))
queued_dttm = Column(UtcDateTime)
pid = Column(Integer)
executor_config = Column(PickleType(pickler=dill))
__table_args__ = (
Index('ti_dag_state', dag_id, state),
Index('ti_dag_date', dag_id, execution_date),
Index('ti_state', state),
Index('ti_state_lkp', dag_id, task_id, execution_date, state),
Index('ti_pool', pool, state, priority_weight),
Index('ti_job_id', job_id),
)
class DagModel(Base):
__tablename__ = "dag"
"""
These items are stored in the database for state related information
"""
dag_id = Column(String(ID_LEN), primary_key=True)
# A DAG can be paused from the UI / DB
# Set this default value of is_paused based on a configuration value!
is_paused_at_creation = configuration.conf\
.getboolean('core',
'dags_are_paused_at_creation')
is_paused = Column(Boolean, default=is_paused_at_creation)
# Whether the DAG is a subdag
is_subdag = Column(Boolean, default=False)
# Whether that DAG was seen on the last DagBag load
is_active = Column(Boolean, default=False)
# Last time the scheduler started
last_scheduler_run = Column(UtcDateTime)
# Last time this DAG was pickled
last_pickled = Column(UtcDateTime)
# Time when the DAG last received a refresh signal
# (e.g. the DAG's "refresh" button was clicked in the web UI)
last_expired = Column(UtcDateTime)
# Whether (one of) the scheduler is scheduling this DAG at the moment
scheduler_lock = Column(Boolean)
# Foreign key to the latest pickle_id
pickle_id = Column(Integer)
# The location of the file containing the DAG object
fileloc = Column(String(2000))
# String representing the owners
owners = Column(String(2000))
# Description of the dag
description = Column(Text)
# Default view of the inside the webserver
default_view = Column(String(25))
# Schedule interval
schedule_interval = Column(Interval)
控制器
<script src="{{JS}}bootstrap-toggle.min.js"></script>
<script src="{{JS}}jquery.dataTables.min.js"></script>
<script src="{{JS}}dataTables.bootstrap.min.js"></script>
<?php $routeValue= $route; ?>
@if(!isset($route_as_url))
{
<?php $routeValue = route($route); ?>
}
@endif
<?php
$setData = array();
if(isset($table_columns))
{
foreach($table_columns as $col) {
$temp['data'] = $col;
$temp['name'] = $col;
array_push($setData, $temp);
}
$setData = json_encode($setData);
}
?>
@if(isset($extra_var))
@if($extra_var==1)
<script>
$(function() {
$('#users-table').DataTable({
processing: true,
serverSide: true,
type: 'GET',
ajax: '{{ $routeValue }}',
@if(isset($user_type))
@if($user_type=='student')
columns: [
{ data: 'roll_no', name: 'roll_no' },
{ data: 'image', name: 'users.image' },
{ data: 'first_name', name: 'first_name' },
{ data: 'last_name', name: 'last_name' },
{ data: 'email', name: 'users.email' }
],
@else
columns: [
{ data: 'staff_id', name: 'staff_id' },
{ data: 'image', name: 'users.image' },
{ data: 'first_name', name: 'first_name' },
{ data: 'last_name', name: 'last_name' },
{ data: 'email', name: 'users.email' }
]
@endif
@endif
});
});
</script>
@endif
@else
<script>
var tableObj;
$(document).ready(function(){
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
tableObj = $('.datatable').DataTable({
processing: true,
serverSide: true,
type: 'GET',
ajax: '{{ $routeValue }}',
@if(isset($table_columns))
columns: '{!!$setData!!}'
@endif
});
});
</script>
@endif