Hi,
I’m new to Yii and using Yii 2.0
I find problem/difficulties when working with GridView.
I have master detail form and i want the detail using GridView, not just regular HTML table.
I have script like this
<?php
$searchModel = new common\models\Purcd();
$dataProvider = new ActiveDataProvider([
'query' => $searchModel::find(),
]);
Pjax::begin();
echo GridView::widget([
'tableOptions' => [
'id'=>'purcd'
],
'dataProvider' => $dataProvider,
'filterModel' => null,
'columns' => [
['attribute' => 'dno'],
['attribute' => 'item_id'],
['attribute' => 'itemname'],
],
]);
Pjax::end();
?>
</div>
With this, it’s display no result found, since i didn’t have data to load.
And this is javascript for adding the row with dummy data
$.fn.add_detail = function() {
var idx = new Date().getTime();
$('#purcd > tbody:last').append('<tr id=\"1\"><td>1</td><td>001</td><td>Duck</td></tr>');
$('#purcd > tbody:last').append('<tr id=\"2\"><td>2</td><td>002</td><td>Chicken</td></tr>');
};
Based on these, i have 2 questions :
-
How to remove "No results found." since i want to use gridview for data manipulation ?
-
When i want to sort the itemname, i’d click on itemname GridView column and the dummy data was gone.
I thought because the dummy data didn’t have any relation to GridView, the dummy data gone.
How to connect my dummy data to GridView ??
Any help/hint really appreciated.