AJAX JSON não retorna dados na JQGRID
Prezados, Boa Noite! Sou novo em desenvolvimento e nunca trabalhei com a função JSON. Estou tentando retorna dados JSON em uma tabela JQGRID, de forma que eu digito no campo input os dados e ele retorna as informações. Bom estou conseguindo fazer ele retorna as informações so que nao aparece nada no meu jqgrid, alguem poderia me ajudar? Segue trecho do codigo: JQGRID: //data: grid_data, url: "@Url.Content("~/UnidadeMedidaFormato/Pesquisar?descricao=")", datatype: "json", //ajaxGridOptions: { contentType: 'application/json. charset=utf-8'}, //serializeGridData: function (postdata) {return JSON.stringify(postdata). }, height: 250, colNames: [' ', '', 'Ativo', 'Descrição', '', ], colModel: [ { name: 'myac', index: '', width: 1, fixed: true, sortable: false, resize: false, hidden: true, }, { name: 'Mensagens', index: 'id', width: 80, sorttype: "int", editable: true, align: 'center', }, { name: 'ATIVO', index: 'AtivoUnidade', width: 60, sorttype: "float", editable: true, edittype: 'checkbox', editoptions: { value: "True:False" }, formatter: "checkbox", formatoptions: { disabled: false }, align: "center", }, { name: 'Descricao', index: 'descricaoUnidade', width: 400, editable: true, editoptions: { size: "20", maxlength: "30" } }, { name: '', index: '', width: 600, sortable: false, editable: true, edittype: "textarea", editoptions: { rows: "2", cols: "10" } } ], jsonReader: { root: "rows", repeatitems: false, id: "id", /, userdata: "userdata", subgrid: {root:"rows", repeatitems: true, cell:"cell" }/ }, viewrecords: true, rowNum: 10, rowList: [10, 20, 30], pager: pager_selector, altRows: true, loadonce: true, toolbar: [true, "top", ], //toppager: true, multiselect: false, //multikey: "ctrlKey", multiboxonly: false,
loadComplete: function () { var table = this. setTimeout(function () { styleCheckbox(table). updateActionIcons(table). updatePagerIcons(table). enableTooltips(table). }, 0). }, editurl: "/dummy.html",//nothing is saved caption: "Listagem de Unidade de Medida de Formato", MEU BOTAO E O INPUT: $("#grid-pager_left").append(' ').add('navgrid'). $('button#botaorodapejqgrid').button({ icons: { primary: 'btnPesquisar' } }).click(function (ev) { var gridViewFilter = $("#campoinputjqgrid").val(). $('#grid-table').setGridParam({ datatype: 'json', url: "@Url.Content("~/UnidadeMedidaFormato/Pesquisar?descricao=")"+gridViewFilter, postData: { msgFilter: gridViewFilter } }). $('#grid-table').trigger("reloadGrid"). }). $("#grid-pager_left").append(' Pesquisar:').add('navgrid'). $("#grid-pager_left").append('').add('navgrid'). $('input#campoinputjqgrid').button({ icons: { primary: 'txtPesquisar' } }).click(function (ev) { }). $("#grid-pager_left").append('').add('navgrid'). $('select#selectjqgrid').button({ icons: { primary: 'cmbPesquisar' } }).click(function (ev) { }). MINHA CONTROLLER: public JsonResult Pesquisar(String descricao) { var tbl = bd.tblunidadeMedidaFormato.Where(x => x.registrodeletado == false && x.descricaoUnidade.IndexOf(descricao) >= 0 || descricao == "" && x.registrodeletado == false).ToList(). var jsonData = new { total = 1, page = 1, records = tbl.Count(), rows = tbl.Select(p => new { id = p.id.ToString(), descricaoUnidade = p.descricaoUnidade, AtivoUnidade = p.AtivoUnidade.ToString() }).ToArray() }. / var jsonData = new { total = totalPages, page = pageIndex, records = count, rows = tbl.Select(p => new { id = p.id.ToString(), descricaoUnidade = p.descricaoUnidade, AtivoUnidade = p.AtivoUnidade.ToString() }).ToArray() }. / return Json(jsonData, JsonRequestBehavior.AllowGet). } ALGUEM ME AJUDAAAA!Discussão (0)
Carregando comentários...