我在webapp上使用datatables作为我的网格.问题是,用户必须始终刷新页面以从数据库中获取当前数据,有没有办法可以自动完成?因为有几个应用程序写入同一个表,而webapp仅用于监控,但如果用户必须刷新页面以获取当前数据,它就会失败.这是我的初始化代码:
$('.{{datatable['class']}}').dataTable( {
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"sSwfPath": "includes/swf/copy_csv_xls_pdf.swf",
"aButtons": [
{
"sExtends":"copy",
"mColumns":[{{datatable['flds']}}]
},
{
"sExtends":"csv",
"mColumns":[{{datatable['flds']}}]
},
{
"sExtends":"xls",
"mColumns":[{{datatable['flds']}}]
},
{
"sExtends": "pdf",
"mColumns":[{{datatable['flds']}}],
"sPdfOrientation": "landscape",
"sPdfMessage": "{{datatable['title']}}"
}
]
},
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "{{datatable['source']}}",
"aoColumns": [
{% for column in 0..datatable['columns']-2 %}
null,
{% endfor %}
null
]
});
Run Code Online (Sandbox Code Playgroud)
有没有一种方法,每当数据源发生任何事情(UPDATE/INSERT/DELETE)时,列表可以自行更新?我已经实现了Danny建议的循环,
var int=self.setInterval(function(){oTable.fnDraw();},1000);
Run Code Online (Sandbox Code Playgroud)
但问题是列表总是一个有趣的状态,看到附着的图像
我有一个模型 Interesttype,我想要验证两个字段,一个不应该多于另一个,并且没有一个应该小于特定的设置值。这是我的模型。
class Interesttype extends AppModel
{
public $primaryKey = 'int_id';
public $displayField = 'int_name';
public $hasMany= array(
'Loan' => array(
'className' => 'Loan',
'foreignKey' => 'lon_int_id'
)
);
public $validate = array(
'int_name'=> array(
'rule' => 'notEmpty',
'allowEmpty' => false,
'message' => 'The interest type name is required.'
),
'int_active'=>array(
'rule'=>array('boolean'),
'allowEmpty'=>false,
'message'=>'Please select the status of this interest type'
),
'int_max'=> array(
'numeric'=>array(
'rule' => 'numeric',
'allowEmpty' => false,
'message' => 'Please specify a valid maximum interest rate.' …
Run Code Online (Sandbox Code Playgroud) 我有一个控制台应用程序,我想使用Nancy托管Web服务。这是我的Program.cs
namespace NancyConsole
{
using Nancy.Hosting.Self;
using System;
internal class Program
{
private static void Main(string[] args)
{
string url = "http://localhost:1234";
var host = new NancyHost(new Uri(url));
host.Start();
Console.WriteLine("Server started, now listening on " + url);
Console.WriteLine("Press any key to stop the server...");
Console.ReadKey();
host.Stop();
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的MainModule.cs文件
namespace NancyConsole
{
using Nancy;
internal class MainModule : NancyModule
{
public MainModule()
{
Get["/"] = x => View["Views/index.html"];
}
}
}
Run Code Online (Sandbox Code Playgroud)
我不知道我要去哪里错了?非常感谢您的帮助!
我在cakephp视图中有一个表单,只需一个按钮即可保存,这里是视图book_form.ctp中的代码
echo $this->Form->create
(
'Book',
array
(
'url' => array
(
'controller' => 'Books',
'action' => 'save_record'
),
'class' => 'span12 the_ajaxform',
'inputDefaults' => array
(
'label' => false,
'error' => false
)
)
);
.
.
// form fields
.
.
$options =array(
'label' => __('Save'),
'class' => 'btn btn-primary',
'id'=>'saveform'
);
echo $this->Form->end($options);
.
.
Run Code Online (Sandbox Code Playgroud)
这完美!现在我想在该表单上添加两个按钮,这就是我所做的
$options =array(array(
'label' => __('Save & Close'),
'class' => 'btn btn-primary',
'id'=>'saveform'
),
array(
'label' => __('Save & Create New'),
'class' => …
Run Code Online (Sandbox Code Playgroud) cakephp ×2
jquery ×2
php ×2
c# ×1
cakephp-2.3 ×1
datatables ×1
forms ×1
long-polling ×1
nancy ×1
phpwebsocket ×1
self-hosting ×1
validation ×1
websocket ×1