When I click the search button in jqGrid, the search pop up is not displaying. I have given search=true, I have done this another project its working fine. I am not getting what's wrong. Is anything missing. Please can any one help this. Or Can any one help how to do manually search functionality in jquery for this.
plugins
<link href="#Url.Content("~/Content/ui.jqgrid.css")" rel="stylesheet" type="text/css" />
<script src="#Url.Content("~/Scripts/grid.locale-en.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.jqGrid.min.js")" type="text/javascript"</script>
view code:
#using (Html.BeginForm())
{
<table id="Channelslistgrid" cellpadding="0" cellspacing="0">
</table>
<div id="pager" name="pager" style="text-align: center;">
</div>
}
Code:
<script type="text/javascript">
$(function () {
$("#Channelslistgrid").jqGrid({
colNames: ['Title', 'Description', 'LogoFileName' ],
colModel: [
{ name: 'Title', index: 'ChannelName', sortable: true, align: 'left', width: '200',
editable: false, edittype: 'text',search:true,searchoptions:{sopt:['eq']}
},
{ name: 'Description', index: 'Description', sortable: false, align: 'left', width: '120',
editable: false, edittype: 'text',search:true,searchoptions:{sopt:['eq']}
},
{ name: 'Logo', index: 'Logo', align: 'left', formatter: unitsInStockFormatter, sortable: false, width: '100',
editable: false,search:false
}
],
pager: jQuery('#pager'),
sortname: 'Title',
rowNum: 15,
rowList: [15, 20, 25],
sortorder: "desc",
height: 345,
viewrecords: true,
rownumbers: true,
caption: 'ChannelsList',
width: 660,
url: "#Url.Content("Urlpathgiven")",
datatype: 'json',
mtype: 'GET'
})
jQuery("#Channelslistgrid").jqGrid('navGrid', '#pager', { edit: false, add: false, del: false, search: true, refresh: true },
{ closeOnEscape: true, reloadAfterSubmit: true, closeAfterEdit: true, left: 400, top: 300 },
{ closeOnEscape: true, reloadAfterSubmit: true, closeAfterAdd: true, left: 450, top: 300, width: 520 },
{ closeOnEscape: true, reloadAfterSubmit: true, left: 450, top: 300 },
{closeAfterSearch:true,closeAfterReset:true,left: 450, top: 300}
);
});
</script>
Include all the Script url and style path in Bundle.Config.
bundles.Add(new ScriptBundle("~/bundles/bundleName").Include(
"~/js/jquery.jqGrid.src.js",
"~/js/jquery-ui-1.8.2.custom.min.js",
"~/js/i18n/grid.locale-en.js"));
bundles.Add(new StyleBundle("~/css").Include("~/css/ui.jqgrid.css");
Add in Layout.cshtml end of file
#Scripts.Render("~/bundles/jquery")
#Scripts.Render("~/bundles/jqueryval")
#Scripts.Render("~/bundles/jqueryui")
#Scripts.Render("~/bundles/bundleName")
Thanks,
BPL
Related
I would like to have my checkbox column operate as if it were a group, ie I can only check a single check box and if I select a different one all other check boxes will be unchecked.
Below is my grid.
colNames: ['PSN', 'Program Name', 'Comp. Year', 'Primary', 'Select'],
colModel: [
{ name: 'PSN', index: 'PSN', width: 5, sortable: false, search: false, align: 'center', editable: false },
{ name: 'ProgramName', index: 'ProgramName', width: 40, sortable: false, search: false, align: 'left', editable: false },
{ name: 'CompletedYear', index: 'CompletedYear', width: 10, sortable: false, search: false, align: 'left', editable: false },
{ name: 'PrimaryPSN', index: 'PrimaryPSN', width: 10, sortable: false, search: false, align: 'center', editable: false }, // ,formatter: PrimaryPSN,
{ name: 'SurveyPSN', index: 'SurveyPSN', width: 10, sortable: false, search: false, align: 'center', editable: true, edittype: 'checkbox', editoptions: { value: "True:False" }, formatter: 'checkbox', formatoptions: { disabled: false } }, //
],
cellEdit:true,
I have thought about adding an afterEdit event but don't know about looping through the grid to clear anyother checked cells.
You can do this by writing you custom function and giving a class to check box and a particular ID.
{ name: 'Action', index: 'Action', width: 80, align: 'center', formatter: function (cell, options, obj) { return "<input type ='checkbox' class='getcheckbox' id ='chkReviewed_" + ID + "' onclick='SelectedId(" + ID + ")'/>" }}
Now in this "SelectedId(ID)" function you can unchecked all the check box based on class and then select the particular check box based on ID.
Hope this will solve you problem
I'm working with Asp.net MVC4, jqgrid 4.4.4 and jquery 1.9
The jqGrid is loaded from a query to the database, but I can not filter the fields, when I put a value doesn't search, it shows me the same values, but when I define in jqgrid the value loadonce: true only in the first search page, How I can resolve this problem? Where I should be modify the code?
This is my code, jqgrid:
jQuery(document).ready(function () {
jQuery("#tbBuscaRec").jqGrid({
url: '#Url.Action("DatosBuscaPersona", "raTabPersonaReclamante")',
datatype: 'json',
mtype: 'POST',
postData: { Parametro: Param },
colNames: ['Id', 'IdPer', 'Doc', 'CI/NIT', 'Nombres', 'Apellido Paterno', 'Apellido Materno', 'Apellido Esposo'],
colModel:
[
{ name: 'ip_idpersona', index: 'ip_idpersona', formatter: 'number', hidden: true },
{ name: 'ip_idpersonadoc', index: 'ip_idpersonadoc', formatter: 'text', hidden: true },
{ name: 'ip_partipodoc', index: 'ip_partipodoc', align: 'left', width: '4', editable: true, edittype: 'text', editoptions: { readonly: true }, search: false },
{ name: 'ip_nrodoc', index: 'ip_nrodoc', sortable: true, align: 'left', width: '8', editable: true, edittype: 'text', editoptions: { readonly: true} },
{ name: 'ip_nombres', index: 'ip_nombres', sortable: true, align: 'left', width: '15', editable: true, edittype: 'text', editoptions: { readonly: true} },
{ name: 'ip_appaterno', index: 'ip_appaterno', sortable: true, align: 'left', width: '15', editable: true, edittype: 'text', editoptions: { readonly: true } },
{ name: 'ip_apmaterno', index: 'ip_apmaterno', sortable: true, align: 'left', width: '15', editable: true, edittype: 'text', editoptions: { readonly: true} },
{ name: 'ip_apesposo', index: 'ip_apesposo', sortable: false, align: 'left', width: '15', editable: true, edittype: 'text', editoptions: { readonly: true} }
],
pager: '#pg_tbBuscaRec',
rowNum: 100,
rowList: [100, 200, 300],
sortname: 'ip_nombres',
sortorder: 'asc',
rownumbers: true,
multiselect: false,
gridview: true,
height: 180,
width: 490,
ignoreCase: true,
// loadonce: true,
});
});
jQuery("#tbBuscaRec").jqGrid('navGrid', '#pg_tbBuscaRec', { view: false, edit: false, add: false, del: false }, {}, {}, {}, { multipleSearch: true, closeAfterSearch: true, closeOnEscape: true });
jQuery("#tbBuscaRec").jqGrid('filterToolbar');
jQuery("#tbBuscaRec").trigger("reloadGrid", [{ current: true}]);
By default the filtering will be handled by your Controller, and you will see these values being passed to the controller in the _search and filters.
The reason the loadonce: true is working on the first page is that it is doing the filtering on the client side.
I would suggest checking out Oleg's answer on filtering at the link below, it is what put me on the track to do server side filtering for my application.
ASP.NET MVC 2.0 Implementation of searching in jqgrid
I'm trying to implement a JQGrid that takes information from my controller, following the approach in this tutorial, http://haacked.com/archive/2009/04/13/using-jquery-grid-with-asp.net-mvc.aspx.
The code for my controller is:
public ActionResult GridData(string sidx, string sord, int page, int rows)
{
var jsonData = new
{
total = 1,
page = page,
records = 1,
rows = new[]
{
new {id = 1, cell = new[] {"", "", "", "", "", "", "f", "", "", "", "", "", "", ""}},
}
};
return Json(jsonData, JsonRequestBehavior.AllowGet);
}
The code for my View is:
<link rel="stylesheet" type="text/css" media="screen" href="css/ui-lightness/jquery-ui- 1.8.23.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.multiselect.css" />
<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function ()
{
jQuery("#list").jqGrid(
{
url: '/WebFormUserList/GridData',
datatype: 'json',
mtype: 'GET',
colNames:
[
'User_ID', 'Forename', 'Surname', 'Client_Code', 'User_Name',
'Password', 'Email', 'Gender', 'Report_Date', 'Email_Date',
'Test_Count', 'Test_Completed', 'Job_Function', 'Lookup_Value'
],
colModel:
[
{ name: 'User_ID', index: 'User_ID', width: 'auto', align: 'centre' },
{ name: 'Forename', index: 'Forename', width: 'auto', align: 'centre' },
{ name: 'Surname', index: 'Surname', width: 'auto', align: 'centre' },
{ name: 'Client_Code', index: 'Client_Code', width: 'auto', align: 'centre' },
{ name: 'User_Name', index: 'User_Name', width: 'auto', align: 'centre' },
{ name: 'Password', index: 'Password', width: 'auto', align: 'centre' },
{ name: 'Email', index: 'Email', width: 'auto', align: 'centre' },
{ name: 'Gender', index: 'Gender', width: 'auto', align: 'centre' },
{ name: 'Report_Date', index: 'Report_Date', width: 'auto', align: 'centre' },
{ name: 'Email_Date', index: 'Email_Date', width: 'auto', align: 'centre' },
{ name: 'Test_Count', index: 'Test_Count', width: 'auto', align: 'centre' },
{ name: 'Test_Completed', index: 'Test_Completed', width: 'auto', align: 'centre' },
{ name: 'Job_Function', index: 'Job_Function', width: 'auto', align: 'centre' },
{ name: 'Lookup_Value', index: 'Lookup_Value', width: 'auto', align: 'centre' },
],
pager: jQuery('#pager'),
height: 'auto',
width: 1000,
rowNum: 10,
rowList: [5, 10, 20, 50],
sortname: 'Id',
sortorder: "desc",
viewrecords: true,
imgpath: '/css/ui-lightness/images',
caption: 'My first grid'
});
});
When I try to call the page for the grid, I get the error below.
The parameters dictionary contains a null entry for parameter 'page' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult GridData(System.String, System.String, Int32, Int32)' in 'HFI_Assessment_Administration.Controllers.WebFormUserListController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
Parameter name: parameters
I would greatly appreciate any help or advice people could offer. If someone could also explain how sidx, sord, page, rows are passed, that would also greatly help my understanding.
Many thanks!
page is not initialized in your example.
try this:
page = 1,
records = 1,
rows = new[]
{
new {id = 1, cell = new[] {"", "", "", "", "", "", "f", "", "", "", "", "", "", ""}},
}
I am currently running the following code:
<script type="text/javascript">
$(document).ready(function() {
var updateDialog = {
url: '<%= Url.Action("ABM", "Periodo") %>'
, closeAfterAdd: true
, closeAfterEdit: true
, modal: true
, afterShowForm: function(formId) {
$("#fecha_inicio").datepicker({ autoSize: true, showOn: 'both', dateFormat: 'dd/mm/yy' });
$("#fecha_fin").datepicker({ autoSize: true, showOn: 'both', dateFormat: 'dd/mm/yy' });
}
, onclickSubmit: function(params) {
var ajaxData = {};
var list = $("#list");
var selectedRow = list.getGridParam("selrow");
rowData = list.getRowData(selectedRow);
ajaxData = { periodoNum: rowData.periodoId };
return ajaxData;
}
, width: "400"
};
$.jgrid.nav.addtext = "Agregar";
$.jgrid.nav.edittext = "Editar";
$.jgrid.nav.deltext = "Borrar";
$.jgrid.edit.addCaption = "Agregar Periodo";
$.jgrid.edit.editCaption = "Editar Periodo";
$.jgrid.del.caption = "Borrar Periodo";
$.jgrid.del.msg = "Borrar el periodo seleccionado?";
$("#list").jqGrid({
url: '<%= Url.Action("List", "Periodo") %>',
datatype: 'json',
mtype: 'GET',
colNames: ['NĂºmero', 'Desde Fecha', 'Hasta Fecha', 'Activo'],
colModel: [
{ name: 'periodoId', index: 'periodoId', width: 40, align: 'left', editable: false, editrules: { edithidden: false }, hidedlg: true, hidden: true },
{ name: 'fecha_inicio', index: 'fecha_inicio', formatter: 'date', datefmt: 'd/m/Y', width: 100, align: 'left', editable: true, edittype: 'text', editoptions: { size: 10, maxlength: 10 }, editrules: { required: true }, formoptions: { elmsuffix: ' *'} },
{ name: 'fecha_fin', index: 'fecha_fin', formatter: 'date', datefmt: 'd/m/Y', width: 100, align: 'left', editable: true, edittype: 'text', editoptions: { size: 10, maxlength: 10 }, editrules: { required: true }, formoptions: { elmsuffix: ' *'} },
{ name: 'activo', index: 'activo', width: 100, align: 'left', editable: true, edittype: 'checkbox', editoptions: { value: "True:False" }, editrules: { required: false} },
],
pager: $('#listPager'),
rowNum: 20,
rowList: [5, 10, 20],
sortname: 'id',
sortorder: "desc",
viewrecords: true,
imgpath: '/Content/ui-lightness/Images',
width: "900",
height: "400",
ondblClickRow: function(rowid, iRow, iCol, e) {
$("#list").editGridRow(rowid, prmGridDialog);
}
}).navGrid('#listPager',
{
edit: true, add: true, del: true, search: false, refresh: true
},
updateDialog,
updateDialog,
updateDialog
);
});
</script>
But when data entry is only possible using only the datepicker of fecha_inicio.
I have read several examples web, but could not find the solution, What am I doing wrong?
apparently the point of failure occurred with
showOn: 'both'
when it was changed to
showOn: 'button'
worked correctly
i m using jqgrid with mvc 3, I want to add Edit and Delete button with every row of JqGrid , i have achieved this thing by the help of this link. But it is for inline editing, i want to open a popup widows when click on edit button.
How can i achieve this thing.
Thanks
You should just use new editformbutton: true option which exists starting with version 4.1.0 of jqGrid:
formatter:'actions',
formatoptions: {
keys: true,
editformbutton: true
}
Please find the colmodel below for editing:
{
name: 'EditAction',
width: 60,
fixed: true,
search: false,
sortable: false,
resize: false,
formatter: 'actions',
formatoptions: {
keys: false,
editbutton: true,
delbutton: false,
editformbutton: false,
onSuccess: function(response) {
if (response.status == 200) {
}
},
extraparam: { oper: 'edit' },
url: '#Url.Action("ActionName", "Controller")'
}
},
jQuery("#grid").jqGrid({
datatype: "local",
data: second,
#url: '#Url.Action("orders", "Home")',
datatype: "json",#
colNames: ['name', 'description', 'url'],
colModel: [
{name: 'name',
index: 'name',
editable: true,
editrules: {required: true},
editoptions: {placeholder: 'Enter a Name'}
},
{name: 'description',
index: 'description',
editable: true,
editrules: {required: true},
editoptions: {placeholder: 'Enter description'}
},
{
name: 'url',
index: 'url',
editable: true,
editrules: {required: true},
editoptions: {placeholder: 'Enter url'}
}
],
rowNum: 10,
rowList: [10, 20, 30],
sortname: 'model',
pager: '#pager',
editrow:true,
editurl: '#Url.Action("orders", "Home")',
viewrecords: true,
sortorder: "desc",
jsonReader: {
repeatitems: false,
id: "0"
},
searching: {
loadFilterDefaults: false,
closeOnEscape: true,
searchOperators: true,
searchOnEnter: true
},
caption: "Cars Grid",
height: '80%',
gridComplete: initGrid
});