Table header filtering via another column
Table header filtering via another column
Andrew_ghosh
Posts: 3Questions: 1Answers: 0
I try to filter a header section of data table, If we select a state in city column show the there own city's only
GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'atmcode:ntext',
'atmname:ntext',
[
'label' => 'State',
'attribute' => 'state',
'value' => 'state',
'filter' => Html::dropDownList('ClubSearch[state]', $searchModel->state, ArrayHelper::map(ClubQuery::getStates(), 'state', 'state'), ['prompt' => '-- Select State --', 'class' => 'form-control', 'id' => 'stateID']),
],
[
'label' => 'City',
'attribute' => 'city',
'value' => 'city',
'filter' => Html::dropDownList('ClubSearch[city]', $searchModel->city, ArrayHelper::map(ClubQuery::getCities(), 'city', 'city'), ['prompt' => '-- Select City --', 'class' => 'form-control', 'id' => 'cityID']),
],
],
]);
and i try filtering via ajax that code is
$( document ).ready(function() {
$("#stateID").on('change', function(e){
var state = $(this).val()
$('#cityID').empty();
$.ajax({
'method': 'GET',
'url': baseurl + 'cms/club/city-from-ajax?id=' + state,
success: function (data) {
if (data === "") {
} else {
$("#cityID").html(data);
}
}
});
})
});
but no response from Ajax request , how we do this filtering , thanks in advance
Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide
Answers
I don't see where Datatables is involved with this code. There is nothing obvious from the code snippets that looks to be a problem. Please post a link to your page or a test case replicating the issues we can understand your code flow and help debug.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
no response from Ajax request it show blank but same ajax code will work in another page or any another way filter city via state
i try to change the value of city from ajax request
Then you will need to debug your server code to find out why the response is empty.
Not sure what city is. Again, without seeing what you have is difficult to offer suggestions.
Please post a link to a test case replicating the issue.
Kevin