尊敬的Stack Overflow社区,感谢您阅读我的问题!,
在我的环境中,我正在使用PHP MVC-Codeigniter和插件Tabulator, Tabulator插件需要AjaxURL才能将数据加载到表中。
正确,当我从db(model)获取数据时,加载到控制器中并在控制器中打印json,然后在Tabulator插件中传递控制器URL,就可以了!
因此,我有一个数据库,选择表单视图,在该视图中,将输入发送(POST)到上述控制器。
我有第三个控制器,它具有制表器插件的视图,其中显示了json表
我需要的是发布数据库,选择表单,发送到控制器,发送到打印Json的控制器,然后加载到AjaxURL中以在Tabulator插件视图上加载数据。
请,请您帮我一下!
我试图将json结果变量从一个控制器传递到另一个控制器,但是通过槽形URL不能正常工作。
这是我的Builder控制器,只需在其中加载数据库选择表单即可。
function builder()
{
$this->global['pageTitle'] = 'SPED Fiscal : Query Builder';
$data['css'] = array(
'plugins/slimSelect/slimselect.min.css'
);
$data['js'] = array(
'plugins/slimSelect/slimselect.min.js'
);
$this->loadViews("queryBuilder", $this->global, $data);
}
这是我的查询控制器,在其中接收下面提到的数据库选择表单输入,并从模型请求数据库查询,最后打印出来。
function query() {
header('Content-Type: application/json');
$parameters = array(
//Primeira linha Principal
'repository' => $this->input->post('query-repository'),
'field' => $this->input->post('query-field'),
// Segunda Linha Filtro 1
'field2' => $this->input->post('query-field2'),
'type' => $this->input->post('query-type'),
'value' => $this->input->post('query-value'),
// Terceira Linha Filtro 2
'field3' => $this->input->post('query-field3'),
'type2' => $this->input->post('query-type2'),
'value2' => $this->input->post('query-value2'),
// Quarta Linha Filtro 3
'field4' => $this->input->post('query-field4'),
'type3' => $this->input->post('query-type3'),
'value3' => $this->input->post('query-value3'),
// Quinta Linha Filtro 4
'field5' => $this->input->post('query-field5'),
'type4' => $this->input->post('query-type4'),
'value4' => $this->input->post('query-value4'),
// Sexta Linha Filtro 5
'field6' => $this->input->post('query-field6'),
'type5' => $this->input->post('query-type5'),
'value5' => $this->input->post('query-value5'),
);
$taskJson = $this->task_model->listQuery($parameters);
print_r(json_encode($taskJson));
}
这是我的List控制器,在其中加载制表器插件,并将表放在mytask视图中,我需要在这里获取我在以下方法中查询的数据,将AjaxURL发送到制表器插件
function list()
{
$this->global['pageTitle'] = 'SPED Fiscal : My Task';
$data['css'] = array(
'dist/css/tabulator/tabulator.css',
'dist/css/tabulator/tabulator_site.css'
);
$data['js'] = array(
'dist/js/tabulator/jquery_wrapper.min.js',
'dist/js/tabulator/tabulator.min.js',
'dist/js/tabulator/tabulator_core.min.js',
'dist/js/tabulator/modules/page.min.js',
'dist/js/tabulator/modules/sort.min.js',
'dist/js/tabulator/modules/select_row.min.js',
'dist/js/tabulator/modules/filter.min.js',
'dist/js/tabulator/modules/ajax.min.js',
'dist/js/tabulator/modules/download.min.js',
'dist/js/tabulator/modules/clipboard.min.js',
'dist/js/tabulator/customMyTask.js'
);
$this->loadViews("mytask", $this->global, $data);
}
这是我的Tabulator插件设置
//create Tabulator on DOM element with id "example-table"
var table = new Tabulator("#example-table-sender", {
height: 670, //
clipboard: true,
clipboardPasteAction: "replace",
layout: "fitColumns", //fit columns to width of table (optional)
ajaxURL:"/sped/task/taskJson",
ajaxConfig:"POST", //ajax HTTP request type
ajaxContentType:"json", // send parameters to the server as a JSON encoded string
virtualDom: true,
ajaxProgressiveLoad:"scroll",
pagination:"local",
paginationSize:18,
paginationSizeSelector:[5, 10,18,20, 100, 1000],
placeholder:"No Data has been selected",
autoColumns:true,
});
我真的需要一种方法,当我发布查询选择表单时,将json结果发送到Ajax URL并加载到此制表器表格插件中。
请你能帮我吗?
非常感谢您。