Datatable on change ajax on checkbox not working, I have a data table and i am trying to update the value of active in the table into 1 if the checkbox is clicked, and 0 if clicked again. It is not even displaying the console log that i have inserted, I do not where to start. Thank you in advance for any help
ShopsController:
public function activeswitch(){
DB::table('shops')
->update(['active'=>1]);
}
blade.php:
<script>
$(document).ready(function () {
table = $('#shops_table').DataTable({
"processing": true,
"serverSide": true,
"ajax": "{{url('api/admin/shops/get-shops')}}",
rowId: "id",
stateSave: true,
dom: 'Bfrtip',
"buttons": [
'excelHtml5',
'pdf',
'print'
],
"order": [[ 0, "desc" ]],
columns: [
{data: 'id'},
{data: 'name'},
{data: 'image', render: function(data){
return "<img src='/storage/uploads/logo/" + data + "' width=auto height='50' />"
}},
{data: 'color'},
{data: 'switch', render: function(data){
return '<label class="switch">' +
' <input type="checkbox" class="checkbox">' +
'<span class="slider round" data-active-value=0>' +
' </span>' +
' </label>';
}},
{data: 'id', 'width' : '10%', render: function(data){
return '<div class="action-buttons">' +
'<i class="fa fa-eye"></i>' +
'<i class="fa fa-pencil"></i>' +
' <form action="shops/'+data+'" method="POST" style="display: inline-block;">' +
'<input type="hidden" name="_method" value="DELETE" />' +
' #csrf' +
'<button class="btn btn-xs btn-rounded btn-danger" type="submit"><i class="fa fa-trash"></i></button>' +
' </form>' +
'</div>';
}}
],
});
});
$( document ).ready(function() {
$(".checkbox").change(function(e){
console.log('hi')
e.preventDefault();
var selct_ = $(this) //declare this
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
url: "{{ route('active.switch') }}",
data:{
'active':$(this).data('active-value')
},
type: "get",
success: function(result){
console.log('hi')
}
});
});
});
</script>
It's not working because you're adding listeners to elements that don't exists yet.
Datatables.js has a callback that runs once it's been drawn, try this:
$(document).ready(function () {
table = $('#shops_table').DataTable({
"processing": true,
"serverSide": true,
"ajax": "{{url('api/admin/shops/get-shops')}}",
rowId: "id",
stateSave: true,
dom: 'Bfrtip',
"buttons": [
'excelHtml5',
'pdf',
'print'
],
"order": [[ 0, "desc" ]],
columns: [
{data: 'id'},
{data: 'name'},
{data: 'image', render: function(data){
return "<img src='/storage/uploads/logo/" + data + "' width=auto height='50' />"
}},
{data: 'color'},
{data: 'switch', render: function(data){
return '<label class="switch">' +
' <input type="checkbox" class="checkbox">' +
'<span class="slider round" data-active-value=0>' +
' </span>' +
' </label>';
}},
{data: 'id', 'width' : '10%', render: function(data){
return '<div class="action-buttons">' +
'<i class="fa fa-eye"></i>' +
'<i class="fa fa-pencil"></i>' +
' <form action="shops/'+data+'" method="POST" style="display: inline-block;">' +
'<input type="hidden" name="_method" value="DELETE" />' +
' #csrf' +
'<button class="btn btn-xs btn-rounded btn-danger" type="submit"><i class="fa fa-trash"></i></button>' +
' </form>' +
'</div>';
}}
],
"fnDrawCallback": function() {
$(".checkbox").change(function (e) {
console.log('hi')
});
}
});
});
Related
I have the next table..
The IDOP column is a key that I'm using for connect in my app instead of email... I would like to be able for filter the IDOP of each user... So the user should only be able to see the rows with
of its corresponding IDOP, how could I filter only his IDOP?
this is the function of my datatable
$('#user_contactabilidadasesor').DataTable({
processing: true,
"scrollX": true,
//serverSide: true,
ajax: {
url: "{{ route('contactabilidadasesor.index') }}",
},
columns: [
{
data: 'idop',
name: 'l.idop',
className: 'uniqueClassName'
},
{
data: 'idop_asesor',
name: 'idop_asesor',
searchable: false, render: function ( data, type, row ) {
if (data == null){ return ''; }else{return (row['idop_asesor'] + ' ' + row['ape_asesor'])};
},
className: 'uniqueClassName'
}
],
});
And this is my query
public function index(Request $request)
{
if($request->ajax())
{
$data = DB::table('tbl_lista_contactabilidad as a')
->select('a.id','a.postventaatcs_id')
->leftjoin('tbl_equipo_postventaatcs as h','h.id','=','a.postventaatc_id')
->leftjoin('users as l','l.id','=','h.asesor_id')
->select(array('a.id','l.name as idop_asesor','l.apellido as ape_asesor','l.idop'));
return DataTables::of($data)
->addColumn('action', function($data){
$button = '<button type="button" name="edit" id="'.$data->id.'" class="edit btn btn-primary btn-sm">Auditar</button>';
//$button .= ' <button type="button" name="edit" id="'.$data->id.'" class="delete btn btn-danger btn-sm">Delete</button>';
return $button;
})
->rawColumns(['action'])
->make(true);
}
return view('contactabilidadasesor');
}
For filtering you have to use ->where('IDOP', auth()->user()->IDOP) (for single user) of ->whereIn('IDOP', [array of filtering idops]) for multiple IDOPs
My view blade that displays the data of all types but I need the specific type only, where i send it by ajax: "{{ route('taxonomies.json',type) }}".How do I send the type that I want from the given type?
<div class="table">
<table id="taxonomyTable">
<thead>
<tr>
<th>SN</th>
<th>Title</th>
<th>Parent</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
</table>
</div>
<div class="modal fade" id="quickModal" tabindex="-1" role="dialog" aria-labelledby="quickModal" aria-hidden="true">
</div>
<input type="hidden" id="type" value="{{ $type }}" />
and the js is:
<script>
$(document).ready(function () {
var type = $('#type').val();
$('#taxonomyTable').DataTable({
processing: true,
serverSide: true,
ajax: "{{ route('taxonomies.json') }}",
columns: [
{
data: 'id',
render: function (data, type, row) {
return '<strong> #' + data + '</strong>';
}
},
{
data: 'title', name: 'title',
render: function (data, type, row) {
return '<strong>' + data + '</strong>';
}
},
{
data: 'parent', name: 'parent',
render: function (data, type, row) {
return '<strong>' + data.title + '</strong>';
}
},
{
data: 'type', name: 'type',
render: function (data, type, row) {
return '<strong>' + data.type+ '</strong>';
}
},
{
data: 'status',
render: function (data, type, row) {
return data === 'Active' ? '<button class="btn btn-outline-success btn-update-status" data-id="' + row.id + '">Active</button>' : '<button class="btn btn-xs btn-outline-danger btn-update-status" data-id="' + row.id + '">Inactive</button>';
}
},
{data: 'action', name: 'action', orderable: false, searchable: false}
]
});
});
</script>
and my route is:
Route::get('/taxonomies/taxonomy-json/{type}', 'Admin\TaxonomyController#taxonomyJson')->name('taxonomies.json');
and my TaxonomyController has:
public function taxonomyJson()
{
$taxonomy = Taxonomy::with('parent')->toJson();
return DataTables::of($taxonomy)
->addIndexColumn()
->addColumn('action', function ($taxonomy) {
return '<div class="table-actions float-left">
<i class="ik ik-edit-2 green"></i>
<i class="ik ik-trash-2 red"></i>
</div>';
})->make();
}
The code mentioned above displays all of the types in the data but I only need the data of given type.Like my types are category, tag, videos,slider,etc and I need the data of types category only.
How can I fetch it?
Change You Input Hidden tag to which include whole route with it's parameters
<input type="hidden" id="type" value="{{ route('taxonomies.json', ['type' => $type]) }}" />
Now, In Your Ajax call pass input hidden type value directly to ajax as url.
var type_url = $('#type').val();
ajax: type_url
This way you don't have to worry about passing dynamic param. value to JS code from PHP code.
& In Your Controller Function
public function taxonomyJson($type=null)
{
$taxonomy = Taxonomy::with('parent')
if ($type) {
$taxonomy = $taxonomy->where('type', $type);
}
$taxonomy = $taxonomy->toJson();
return DataTables::of($taxonomy)
->addIndexColumn()
->addColumn('action', function ($taxonomy) {
return '<div class="table-actions float-left">
<i class="ik ik-edit-2 green"></i>
<i class="ik ik-trash-2 red"></i>
</div>';
})->make();
}
From your question as far I understood that you want filtered data, in order to get filtered data you needed to pass a filter type which you must use to filter your query. Here is an example for you
if ($request->ajax()) {
$users = User::select(
'users.id',
'users.name',
'users_details.first_name',
'users_details.last_name',
'users.email',
'users.membership_no',
'users.is_active',
'users.created_at'
)
->leftJoin('users_details', 'users.id', '=', 'users_details.users_id')
->where('user_group', '<>', 'admin')
->where(function ($query) use ($request) {
$genery = $request->get("genere");
$varsitySession = $request->get("varsity_session");
$yearOfPassing = $request->get("year_of_passing");
$department = $request->get("department");
$bloodGroup = $request->get("blood_group");
$membership = $request->get("membership");
if (isset($genery) && $genery) {
$query->where('users_details.genre', $genery);
}
if (isset($varsitySession) && $varsitySession) {
$query->where('users_details.varsity_session', $varsitySession);
}
if (isset($yearOfPassing) && $yearOfPassing) {
$query->where('users_details.year_of_passing', $yearOfPassing);
}
if (isset($department) && $department) {
$query->where('users_details.department', $department);
}
if (isset($bloodGroup) && $bloodGroup) {
$query->where('users_details.blood_group', $bloodGroup);
}
if (isset($membership) && $membership) {
$query->where('users_details.membership', $membership);
}
if (isset($request->requested) && $request->requested == 0) {
$query->where('users.membership_no', $request->requested);
}
})
->get();
return Datatables::of($users)
->editColumn('name', function ($users) {
return ($users->first_name) ? $users->first_name . ' ' . $users->last_name : $users->name;
})
->editColumn('is_active', function ($users) {
return ($users->is_active) ? 'Active' : 'De-active';
})
->editColumn('membership_no', function ($users) {
return ($users->membership_no) ? $users->membership_no : 'Not Assigned';
})
->editColumn('created_at', function ($users) {
return $users->created_at->toDayDateTimeString();
})
->make(true);
}
Here you can see that I'm generating a query with where clause which are generated from request data
$genery = $request->get("genere");
$varsitySession = $request->get("varsity_session");
$yearOfPassing = $request->get("year_of_passing");
$department = $request->get("department");
$bloodGroup = $request->get("blood_group");
$membership = $request->get("membership");
Here genere,varsity_session,year_of_passing,department,blood_group,membership are my filter data I'm sending with request.
here is my data table code
$('.dataTable').dataTable({
destroy: true,
paging: true,
searching: true,
sort: true,
processing: true,
serverSide: true,
"ajax": {
url: '{{ url('users/datatable')}}',
type: 'POST',
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
'data': function (d) {
d.genere = $("#genere").val();
d.varsity_session = $("select[name = varsity_session]").val();
d.year_of_passing = $("select[name = year_of_passing]").val();
d.department = $("select[name = department]").val();
d.blood_group = $("input[name = blood_group]").val();
d.membership = $("select[name = membership]").val();
d.paymentStatus = $("select[name = paymentStatus]").val();
d.requested = $("select[name = requested]").val();
}
},
"columns": [
{data: 'id'},
{data: 'name'},
{data: 'email'},
{data: 'membership_no'},
{data: 'is_active'},
{data: 'varsity_session'},
{data: 'due_amount'},
{data: 'paid_amount'},
{data: 'created_at'},
{data: 'last_transaction_date'},
{data: 'action'},
],
"columnDefs": [
{"bSortable": false, "targets": [1, 6]},
{"searchable": false, "targets": [4, 6]}
],
lengthMenu: [[10, 50, 100, -1], [10, 50, 100, "All"]],
pageLength: 10,
"dom": 'Blfrtip',
buttons: [
{
extend: 'copy',
text: 'copy',
className: 'btn btn-primary',
exportOptions: {
columns: 'th:not(:last-child)'
}
},
{
extend: 'csv',
text: 'csv',
className: 'btn btn-warning',
exportOptions: {
columns: 'th:not(:last-child)'
}
},
{
extend: 'excel',
text: 'excel',
className: 'btn btn-danger',
exportOptions: {
columns: 'th:not(:last-child)'
}
},
{
extend: 'pdf',
text: 'pdf',
className: 'btn btn-success',
exportOptions: {
columns: 'th:not(:last-child)'
}
},
{
extend: 'print',
text: 'print',
className: 'btn btn-btn-info',
exportOptions: {
columns: 'th:not(:last-child)'
}
}
]
});
});
And my Static Html code
<div class="row">
<div class="col-lg-12">
<div class="table-responsive">
<table class="display compact dataTable">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Membership No</th>
<th>Status</th>
<th>Versity Session</th>
<th>Due Amount</th>
<th>Paid Amount</th>
<th>Created At</th>
<th>Last Transaction</th>
<th>Action</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<!-- /.col-lg-12 -->
</div>
I have table view with datatables yajra . before i using datatable my delete is normaly ,but after using datatables my delete have error like this
The GET method is not supported for this route. Supported methods: DELETE.
i using route delete but its didint work . can you correct my code ?
view
<div class="box-body table-responsive no-padding">
<table class="table table-hover" id="table">
<tbody><tr>
<thead>
{{-- <th>No</th> --}}
<th>Nama Alat</th>
<th>Waktu</th>
<th>User Input</th>
<th>Action</th>
<th>Edit</th>
<th>Hapus</th>
<th>Tanggal</th>
</thead>
</tr>
#push('scripts')
<script>
$(function () {
$('#table').DataTable({
processing: true,
serverSide: true,
responsive: true,
ajax: '{!! route('adminshow1dt') !!}',
columns: [
{data: 'alat.nama_alat', name: 'alat.nama_alat'},
{data: 'status', name: 'pemeliharaan.status'},
{data: 'user.name', name: 'user.name'},
{data: 'action', name: 'action', orderable: false, searchable: false},
{data: 'edit', name: 'edit', orderable: false, searchable: false},
{data: 'hapus', name: 'hapus', orderable: false, searchable: false},
{data: 'created_at', name: 'created_at'},
],
});
})
</script>
#endpush
my controller and route
public function show()
{
// $pemeliharaan = Pemeliharaan::all();
// $pemeliharaan = Pemeliharaan::find($id);
$pemeliharaan = Pemeliharaan::with(['user', 'alat'])->where('status', 'harian')->get();
return view('admin.view_harian', ['pemeliharaan' => $pemeliharaan]);
}
public function indexDataTablesh()
{
$pemeliharaan = Pemeliharaan::with(['user', 'alat'])->where('status', 'harian')->get();
return Datatables::of($pemeliharaan)
->addColumn('action', function ($pemeliharaan) {
return '<i class="glyphicon glyphicon-eye-open"></i> View Data';
})
->editColumn('edit', function ($pemeliharaan) {
return '<i class="glyphicon glyphicon-edit"></i> Edit';
})
->editColumn('hapus', function ($pemeliharaan) {
return '<i class="glyphicon glyphicon-remove-circle"></i> Hapus';
})
->rawColumns(['hapus' => 'hapus', 'action' => 'action', 'edit' => 'edit'])
->make(true);
}
Routes
Route::delete('/admin/delete1/{id}', 'adminController#destroy1' )->name('delete1');
Route::get('admin/show1', 'adminController#show')->name('adminshow1');
Route::get('admin/show1-dt', 'adminController#indexDataTablesh')->name('adminshow1dt');
can you correct this code plz ?
Try add a form to your action column, notice we have method_field "delete" and csrf_field
$c = csrf_field();
$m = method_field('DELETE');
return "<form action='admin/delete1/$pemeliharaan->id' method='POST'>
$c
$m
<button style='margin-left:10px; width: 150px;' type='submit'
class='btn btn-xs btn-danger'>
<i class='glyphicon glyphicon-remove-circle'></i> Hapus
</button>
</form>"
yaa, ok I got it actually a tag not support delete method if you want to use delete method then you have to use form else use get method in a tag.
Route::get('/admin/delete1/{id}', 'adminController#destroy1' )->name('delete1');
Hope this helps :)
I am trying to return an attribute tag from controller to front-end side but attribute link and class is not working.
Click here (image)
Controller Side
public function religionlist(){
$view_data = DB::select("SELECT
id,religion
FROM
hrm_religion");
$religion_data = collect($view_data);
return DataTables::of($religion_data)
->addColumn('Link', function ($religion_data) {
return
' <a href="'. url('/religion') . '/' .
Crypt::encrypt($religion_data->id) .
'/edit' .'"' .
'class="btn btn-success btn-sm block btn-flat"><i class="glyphicon glyphicon-edit-sign" id="customer-confrimed"></i> confirm</a>';
})
->editColumn('id', '{{$id}}')
->setRowId('id')
->make(true);
}
Front-end Side
$(document).ready(function() {
var table = $('#list_table').DataTable( {
"processing": true,
"serverSide": true,
"paging": true,
"ajax": "{{URL::to('/')}}/religion_list",
"columns": [
{ "data": "religion" },
{ "data": "Link", name: 'action', orderable: false, searchable: false},
],
"order": [[0, 'asc']]
});
});
Can you replace your return statement with below one?
return '<i class="glyphicon glyphicon-edit-sign" id="customer-confrimed"></i> Confirm'
Please review this below link
https://github.com/yajra/laravel-datatables/issues/1305
just add ->rawColumns(['Link']) in your code.
return DataTables::of($religion_data)
->addColumn('Link', function ($religion_data) {
return
' <a href="'. url('/religion') . '/' .
Crypt::encrypt($religion_data->id) .
'/edit' .'"' .
'class="btn btn-success btn-sm block btn-flat"><i class="glyphicon glyphicon-edit-sign" id="customer-confrimed"></i> confirm</a>';
})
->editColumn('id', '{{$id}}')
->setRowId('id')
->rawColumns(['Link'])
->make(true);
I have multiple grids in a page which are shown based on a drop down selection. The first time when the page is loaded and I select another grid name in the drop down that grid's data reload event is not fired but subsequent events fire properly. Can someone let me know what is the problem with first time event not getting fired?
The flow of the execution is as follows
On the page load all the grids numbered 2 to 4 are initialized without any URL. And grid 1 is loaded with data and shown to the user.
Also on page load other grid divs are hidden.
When a user selects any other grid name in the drop down that grids div is shown and a reload event is fired to load data with URL.
HTML code
<select id="gridType" onchange="javascript:onChangeGridType();">
<option value="1" selected="selected">Grid 1</option>
<option value="2">Grid 2</option>
<option value="3">Grid 3</option>
<option value="4">Grid 4</option>
</select>
<div id="grid1Div">
<table id="grid1">
<tr>
<td />
</tr>
</table>
<div id="pager1"></div>
</div>
<div id="grid2Div">
<table id="grid2">
<tr>
<td />
</tr>
</table>
<div id="pager2"></div>
</div>
<div id="grid3Div">
<table id="grid3">
<tr>
<td />
</tr>
</table>
<div id="pager3"></div>
</div>
<div id="grid4Div">
<table id="grid4">
<tr>
<td />
</tr>
</table>
<div id="pager4"></div>
</div>
Grid 1 initialization code
$("#grid1").jqGrid({
url: grid1URL,
datatype: 'json',
mtype: 'GET',
colNames:['column1',
'column2',
'column3'
],
colModel:[
{name:'col1',index:'col2',
width:140,sortable:true,editable:true},
{name:'col2',index:'col2',
width:120,sortable:true,editable:true},
{name:'col3',index:'col3',
width:160,sortable:true,editable:true}
],
pager: '#pager1',
paging:true,
rowNum:perPageRecords,
height:'auto',
loadonce: true,
sortorder: 'desc',
sortname:'col2',
viewrecords: true,
caption: 'Grid 1',
gridview:true,
width:'100%',
autowidth:true,
pginput:true,
ignoreCase:true,
shrinkToFit:false
});
$("#grid1").jqGrid('navGrid',"#pager1",{add:false, edit:false, del:false, search:true, refresh:true,
beforeRefresh: function(){....}},{},{},{},{});
Grid 2 initialization code
$("#grid2").jqGrid({
url: "",
datatype: 'json',
mtype: 'GET',
colNames:['column1',
'column2',
'column3'
],
colModel:[
{name:'col1',index:'col2',
width:140,sortable:true,editable:true},
{name:'col2',index:'col2',
width:120,sortable:true,editable:true},
{name:'col3',index:'col3',
width:160,sortable:true,editable:true}
],
pager: '#pager2',
paging:true,
rowNum:perPageRecords,
height:'auto',
loadonce: true,
sortorder: 'desc',
sortname:'col2',
viewrecords: true,
caption: 'Grid 2',
gridview:true,
width:'100%',
autowidth:true,
pginput:true,
ignoreCase:true,
shrinkToFit:false
});
$("#grid2").jqGrid('navGrid',"#pager2",{add:false, edit:false, del:false, search:true, refresh:true,
beforeRefresh: function(){....}},{},{},{},{});
Grid 3 initialization code
$("#grid3").jqGrid({
url: "",
datatype: 'json',
mtype: 'GET',
colNames:['column1',
'column2',
'column3'
],
colModel:[
{name:'col1',index:'col2',
width:140,sortable:true,editable:true},
{name:'col2',index:'col2',
width:120,sortable:true,editable:true},
{name:'col3',index:'col3',
width:160,sortable:true,editable:true}
],
pager: '#pager3',
paging:true,
rowNum:perPageRecords,
height:'auto',
loadonce: true,
sortorder: 'desc',
sortname:'col2',
viewrecords: true,
caption: 'Grid 3',
gridview:true,
width:'100%',
autowidth:true,
pginput:true,
ignoreCase:true,
shrinkToFit:false
});
$("#grid3").jqGrid('navGrid',"#pager3",{add:false, edit:false, del:false, search:true, refresh:true,
beforeRefresh: function(){....}},{},{},{},{});
Grid 4 initialization code
$("#grid4").jqGrid({
url: "",
datatype: 'json',
mtype: 'GET',
colNames:['column1',
'column2',
'column3'
],
colModel:[
{name:'col1',index:'col2',
width:140,sortable:true,editable:true},
{name:'col2',index:'col2',
width:120,sortable:true,editable:true},
{name:'col3',index:'col3',
width:160,sortable:true,editable:true}
],
pager: '#pager4',
paging:true,
rowNum:perPageRecords,
height:'auto',
loadonce: true,
sortorder: 'desc',
sortname:'col2',
viewrecords: true,
caption: 'Grid 4',
gridview:true,
width:'100%',
autowidth:true,
pginput:true,
ignoreCase:true,
shrinkToFit:false
});
$("#grid4").jqGrid('navGrid',"#pager4",{add:false, edit:false, del:false, search:true, refresh:true,
beforeRefresh: function(){....}},{},{},{},{});
onChangeGridType function
function onChangeGridType(){
var type = $("#gridType").val();
if (type == 1){
reloadGrid1();
$("#grid1Div").show();
$("#grid2Div").hide();
$("#grid3Div").hide();
$("#grid4Div").hide();
$("#grid1Div").css("visibility", "visible");
$("#grid2Div").css("visibility", "hidden");
$("#grid3Div").css("visibility", "hidden");
$("#grid4Div").css("visibility", "hidden");
} else if (type == 2){
reloadGrid2();
$("#grid1Div").hide();
$("#grid2Div").show();
$("#grid3Div").hide();
$("#grid4Div").hide();
$("#grid1Div").css("visibility", "hidden");
$("#grid2Div").css("visibility", "visible");
$("#grid3Div").css("visibility", "hidden");
$("#grid4Div").css("visibility", "hidden");
} else if (type == 3){
reloadGrid3();
$("#grid1Div").hide();
$("#grid2Div").hide();
$("#grid3Div").show();
$("#grid4Div").hide();
$("#grid1Div").css("visibility", "hidden");
$("#grid2Div").css("visibility", "hidden");
$("#grid3Div").css("visibility", "visible");
$("#grid4Div").css("visibility", "hidden");
} else if (type == 4) {
reloadGrid4();
$("#grid1Div").hide();
$("#grid2Div").hide();
$("#grid3Div").hide();
$("#grid4Div").show();
$("#grid1Div").css("visibility", "hidden");
$("#grid2Div").css("visibility", "hidden");
$("#grid3Div").css("visibility", "hidden");
$("#grid4Div").css("visibility", "visible");
}
}
'reload functions`
function reloadGrid1() {
$("#grid1").jqGrid('setGridParam',{datatype : 'json',url : grid1URL}).trigger('reloadGrid', [ {page : 1} ]);
}
function reloadGrid2() {
$("#grid2").jqGrid('setGridParam',{datatype : 'json',url : grid2URL}).trigger('reloadGrid', [ {page : 1} ]);
}
function reloadGrid3() {
$("#grid3").jqGrid('setGridParam',{datatype : 'json',url : grid3URL}).trigger('reloadGrid', [ {page : 1} ]);
}
function reloadGrid4() {
$("#grid4").jqGrid('setGridParam',{datatype : 'json',url : grid4URL}).trigger('reloadGrid', [ {page : 1} ]);
}
For other grids I changed the grid URL value to empty and datatype as "local" that did the trick.