(VUE3) Fullcalendar change month/year NOT working - fullcalendar

I'm designing a log display screen using vue3 and fullcalendar and logs(events) are dynamically loaded into the calendar. 400+ events are rendering successfully in the calendar but this time the month/year toggle buttons are not working and console doesn't show any errors.
here is my calendarOptions and some functions;
calendarOptions: {
plugins: [dayGridPlugin, interactionPlugin],
initialView: "dayGridMonth",
headerToolbar: {
start: "",
center: "title",
end: "today,prev,next,prevYear,nextYear",
},
eventDidMount: function (info) {
var tooltip = new tippy(info.el, {
content: info.event.extendedProps.description,
});
},
events: [],
eventClick: function (info, event, element) {
if (info.event.extendedProps.description == "Download") {
console.log(
"Downloading event:",
info.event.extendedProps.fileName
);
Notify.create({
color: "info",
position: "bottom-left",
message: "Downloading File: " + info.event.extendedProps.fileName,
icon: "folder_open",
});
const url =
"http://10.10.22.14:3333" + info.event.extendedProps.logUrl;
axios({
url,
method: "GET",
responseType: "blob", // important
})
.then((response) => {
const url = window.URL.createObjectURL(
new Blob([response.data])
);
const link = document.createElement("a");
link.href = url;
link.setAttribute(
"download",
`${info.event.extendedProps.fileName}`
);
document.body.appendChild(link);
link.click();
})
.catch((error) => {
console.error(error.message);
Notify.create({
color: "negative",
position: "bottom-right",
message: error.message,
icon: "report_problem",
});
});
}
if (info.event.extendedProps.description == "Check") {
console.log("Checking event:", info.event.extendedProps.fileName);
Notify.create({
color: "info",
position: "bottom-left",
message: "Checking Logs: " + info.event.extendedProps.fileName,
icon: "safety_check",
});
}
if (info.event.extendedProps.description == "Share") {
console.log("Sharing event:", info.event.extendedProps.fileName);
Notify.create({
color: "info",
position: "bottom-left",
message: "Sharing Logs: " + info.event.extendedProps.fileName,
icon: "share",
});
}
},
}
method of calling dynamic log (events);
getData(Seckey) {
let eventGuid = 0;
this.data = [];
this.log1 = [];
this.log2 = [];
this.events = [];
this.logs = [];
axios
.get(
"http://10.10.22.14:3333/getkamusinglogs?secretkey=" +
Seckey +
"&filter=zip"
)
.then((response) => {
let logs = [];
const data = response.data;
// for (let key in data) {
let yearChildren = data[1]["children"];
for (let year in yearChildren) {
let monthChildren = yearChildren[year]["children"];
for (let month in monthChildren) {
logs = logs.concat(monthChildren[month]["children"]);
// logs = logs.slice(10);
}
}
// }
logs.forEach((item) => {
item.start = item.birthtime.substring(0, 10);
item.url = item.path;
item.size =
item.size > 1048576
? (item.size / 1048576).toFixed(2) + " MB"
: (item.size / 1024).toFixed(2) + " KB";
// console.log(`${item.size}`);
delete item.birthtime;
delete item.path;
this.events.push(
{
id: createEventId(),
title: "A Download",
description: "Download",
logUrl: `${item.url}`,
start: `${item.start}`,
// url: `http://10.10.22.14:3333/${item.url}`,
eventDisplay: "block",
className: " download-btn",
extendedProps: {
size: `${item.size}`,
fileName: `${item.name}`,
logUrl: `${item.url}`,
},
},
{
id: createEventId(),
title: "B Check",
description: "Check",
start: `${item.start}`,
// url: `http://10.10.22.14:3333/${item.url}`,
eventDisplay: "block",
className: "save-btn",
extendedProps: {
size: `${item.size}`,
fileName: `${item.name}`,
logUrl: `${item.url}`,
},
},
{
id: createEventId(),
title: "C Share",
description: "Share",
start: `${item.start}`,
// url: `http://10.10.22.14:3333/${item.url}`,
eventDisplay: "block",
className: "share-btn",
extendedProps: {
size: `${item.size}`,
fileName: `${item.name}`,
logUrl: `${item.url}`,
},
}
);
});
console.log("ALL_LOGS \n", logs);
})
.then(() => {
this.calendarOptions.events = this.events;
console.log("ALL_EVENTS \n", this.events);
})
.catch((error) => {
console.error(error);
Notify.create({
color: "warning",
position: "bottom-right",
message: error.message,
icon: "report_problem",
});
});
function createEventId() {
return String(eventGuid++);
}
},
Since the log records are live via a private api, it is not possible for me to create a live test code snipped, but uploading 400+ log records to the calendar is successful, but the month/year change buttons do not work. if i ridiculously want to view the first 100 of records it renders successfully and no problem

Related

Ajax and error cannot read properties of undefined

So I am trying to get some data from a table using ajax but this error keeps popping up and I know its related to parameters but I have none of the parameters it says are wrong anyone got any ideas?
I am working in asp.net 6 and am trying to get the data to a controller.
I am currently working in C# and ajax
(function () {
"use strict"
window.onload = function () {
//Reference the DropDownList.
var ddlYears = document.getElementById("ddlYears");
//Determine the Current Year.
var currentYear = (new Date()).getFullYear() + 10;
var less = (new Date()).getFullYear() - 10;
//Loop and add the Year values to DropDownList.
for (var i = less; i <= currentYear; i++) {
var option = document.createElement("OPTION");
option.innerHTML = i;
option.value = i;
ddlYears.appendChild(option);
}
};
var ScopeTable;
$(document).ready(function () {
ScopeTable = $("#tblScopeView").DataTable({
dom: "Bfrtip",
paging: true,
pagingType: "full_numbers",
buttons: [
"csvHtml5"
],
columns: [
{ data: 'WBS' },
{ data: 'Title' },
{ data: 'Rev' },
{ data: 'ScopeStatus' },
{ data: 'BCP' },
{ data: 'BCPApprovalDate' },
{ data: 'Manager' },
{ data: 'ProjectControlManager' },
{ data: 'ProjectControlEngineer' },
{
mRender: function (data, type, row) {
return "<i class='fa fa-edit btnAddEditScope'></i><span> Edit</span >"
},
class: "btnAddEditScope table-button",
orderable: false
},
{
mRender: function (data, type, row) {
return "<i class='fa fa-trash btnDeleteRow'></i><span> Delete</span >"
},
orderable: false,
class: "table-button"
}
],
createdRow: function (row, data, index) {
$(row).attr("data-id", data.WBSNumber);
$(row).attr("data-month", data.FiscalMonth);
$(row).attr("data-year", data.FiscalYear);
}
});
$(document).on("click", ".btnAddEditScope", btnAddEditScope_click);
$("#spnrSave").hide();
});
function btnAddEditScope_click() {
console.log("button clicked")
$.ajax({
url: "Scope/AddEditScope",
type: "GET",
success: function () {
$("#vw_AddEditScope").modal("show");
}
});
}
}());
Error that is being posted
Figured it out just had do adjust my ajax and it worked fine. The tutorial I found is here https://datatables.net/examples/api/multi_filter.html
var ScopeTable;
$(document).ready(function (e) {
ScopeTable = $("#tblScopeView").DataTable({
dom: "Bfrtip",
paging: true,
pagingType: "full_numbers",
buttons: [
"csvHtml5"
],
columns: [
{ data: 'WBS' },
{ data: 'Title' },
{ data: 'Rev' },
{ data: 'ScopeStatus' },
{ data: 'BCP' },
{ data: 'BCPApprovalDate' },
{ data: 'Manager' },
{ data: 'ProjectControlManager' },
{ data: 'ProjectControlEngineer' },
{
mRender: function (data, type, row) {
return "<i class='fa fa-edit btnAddEditScope'></i><span> Edit</span >"
},
class: "btnAddEditScope table-button",
orderable: false
}, {
mRender: function (data, type, row) {
return "<i class='fa fa-trash btnDeleteRow'></i><span> Delete</span >"
},
orderable: false,
class: "table-button"
},
],
createdRow: function (row, data, index) {
$(row).attr("data-id", data.WBSNumber);
$(row).attr("data-month", data.FiscalMonth);
$(row).attr("data-year", data.FiscalYear);
},
error: function (e) {
console.log(e);
}
});
$('#tblScopeView tfoot th').each(function () {
var title = $("#tblScopeView").eq($(this).index()).text();
$(this).html('<input type="text" class="form-control" placeholder="Search ' + title + '" />');
ScopeTable.columns().every(function () {
var dataTableColumn = this;
$(this.footer()).find('input').on('keyup change', function () {
dataTableColumn.search(this.value).draw();
});
});
});
$("#spnrSave").hide();
$(document).on("click", ".btnAddEditScope", btnAddEditScope_click);
});

FullCalender 5 Unable to render dynamic events & resources

I am trying to render events and resources which are stored in a database. I can get the calendar to render with predefined data for events and resources, however when I push data into the array's, the new objects do not appear when the calendar is rendered.
This is the JS code I am using to obtain the data and render the calendar;
function GetCalenderDetails() {
$.ajax({
url: 'myapiendpoint',
type: 'GET',
success: function (response) {
$.each(response.bookedServices, function (i, v) {
services.push({
id: v.id,
title: v.title
});
});
console.log(JSON.stringify(services));
$.each(response.userBookings, function (i, v) {
bookings.push({
id: v.id,
resourceId: v.resourceId,
title: v.title,
start: v.start,
allDay: v.allDayFlag
});
});
console.log(JSON.stringify(bookings));
calendar.render();
},
error: function (error) {
console.log(error);
}
});
}
var bookings = new Array({ id: '1', resourceId: 'a', title: 'Meeting', start: '2021-03-14', allDay: true });
var services = new Array({ id: 'a', title: 'Room A' });
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
schedulerLicenseKey: 'CC-Attribution-NonCommercial-NoDerivatives',
timeZone: 'UTC',
initialView: 'resourceTimelineDay',
aspectRatio: 1.5,
headerToolbar: {
left: 'prev,next',
center: 'title',
right: 'resourceTimelineDay,resourceTimelineWeek,resourceTimelineMonth'
},
editable: true,
resourceAreaHeaderContent: 'Resources',
resources: services,
events: bookings
});
GetCalenderDetails();
The following is the console output of the 'services' and 'bookings' variables after the GetCalenderDetails function is executed;
Resources Output
[{"id":"a","title":"Room A"},{"id":"b","title":"Room B"}]
Events Output
[{"id":"1","resourceId":"a","title":"Meeting","start":"2021-03-14","allDay":true},
{"id":"2","resourceId":"b","title":"Meeting B","start":"2021-03-15","allDay":true}]
The first resource and event will render, however the second item which is pushed into the array from the GetCalenderDetails function do not render.
I am probably missing something very obvious, but I am not seeing it, so another set of eyes might help :)
As suggested by ADyson's comments, here is the solution to my problem just in case anyone else ends up in the same position;
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
schedulerLicenseKey: 'CC-Attribution-NonCommercial-NoDerivatives',
timeZone: 'UTC',
initialView: 'resourceTimelineDay',
headerToolbar: {
left: 'prev,next,today',
center: 'title',
right: 'resourceTimelineDay,resourceTimelineWeek,resourceTimelineMonth'
},
editable: true,
resourceAreaHeaderContent: 'Booked Services',
resources: function (info, successCallback, failureCallback) {
$.ajax({
url: 'myapiendpoint',
type: 'GET',
success: function (response) {
var resources = [];
console.log(response);
if (response.status == true) {
$.each(response.bookedServices, function (i, v) {
resources.push({
id: v.id,
title: v.title
});
});
} else {
//Do something
}
return successCallback(resources);
},
error: function (error) {
console.log(error);
}
});
},
events: function (info, successCallback, failureCallback) {
$.ajax({
url: 'myapiendpoint',
type: 'GET',
success: function (response) {
var events = [];
console.log(response);
if (response.status == true) {
$.each(response.userBookings, function (i, v) {
events.push({
id: v.id,
title: v.title,
start: v.start,
allDay: v.allDayFlag
});
});
} else {
//Do something
}
return successCallback(events);
},
error: function (error) {
console.log(error);
}
});
}
});
calendar.render();

Filtering SelectControl items according the input from another SelectControl in Gutenberg Block (ES5, no JSX)

I have 2 SelectControl from a Wordpress Gutenberg Custom Block I'm trying to build. I don't use ES6. Only ES5 and no JSX.
The 2 SelectControl should work in the following way:
They fetch from REST WP Api the Post Types and all the Posts. What I want to achieve is when I select an item from SelectControl 1 (Post Types) , I get the related filtered Posts in SelectControl 2. All the posts and post types are preloaded in array at page load.
I'm able with the code below to successfully populate both controls with the REST Api, but when it comes to filter the second selectcontrol according the selected value from the firstcontrol it doesn't work. No errors.
onChange: function(value) {
selectedType = value;
}
The code above doesn't sort any effect. Also no errors. Cannot figure out what is wrong here
(function(wp) {
var registerBlockType = wp.blocks.registerBlockType;
var InspectorControls = wp.blockEditor.InspectorControls;
var PanelBody = wp.components.PanelBody;
var TextControl = wp.components.TextControl;
var ColorPalette = wp.components.ColorPalette;
var SelectControl = wp.components.SelectControl;
var Dashicon = wp.components.Dashicon;
var el = wp.element.createElement;
var withState = wp.compose.withState;
var __ = wp.i18n.__;
var options = [{
value: 0,
label: __('Select a Post...')
}];
var optionsfiltered = null;
var selectedType = '';
var posttypeOptions = [{
value: 0,
label: __('Select a Post Type...')
}];
wp.apiFetch({
path: '/custom/v1/all-posts'
}).then(function(posts) {
var optionsAppend = posts.map(function(post) {
return {
value: post.id,
label: post.title,
type: post.type
}
});
options = options.concat(optionsAppend);
optionsfiltered = options;
});
wp.apiFetch({
path: '/wp/v2/types'
}).then(function(posttypes) {
console.log(posttypes);
for (let [key, item] of Object.entries(posttypes)) {
posttypeOptions.push({
value: item.slug,
label: item.name
});
}
});
function TestControl(props) {
var attributes = props.attributes;
var setAttributes = props.setAttributes;
var setState = props.setState;
var inspectorControl = el(InspectorControls, {},
el('h4', {}, el('span', {}, "Select Value")),
el(SelectControl, {
label: "Select a Post Type",
value: attributes.selectedPost,
options: posttypeOptions,
style: {
fontSize: '10px'
},
onChange: function(value) {
selectedType = value;
}
}),
el(SelectControl, {
label: "Select a Post",
value: attributes.selectedPost,
options: optionsfiltered.filter(function(el) {
return el.type === selectedType;
}),
style: {
fontSize: '10px'
},
onChange: function(value) {
setAttributes({
url: value
});
}
})
);
return el('div', {
style: {
backgroundColor: attributes.color,
color: "#00ff00"
}
},
inspectorControl
);
}
registerBlockType('resorcedomain/resource-cards-block', {
title: __('Resource Cards'),
category: 'widgets',
icon: {
foreground: '#46aaf8',
src: 'store'
},
attributes: {
posts: {
type: 'string',
default: null
},
orders: {
type: 'string',
default: null
},
tagfilter: {
type: 'string',
default: null
}
},
edit: withState({})(TestControl),
save: function(props) {
return null;
}
});
})(window.wp);
I forgot that wordpress is not 100% react. So i had to use setAttributes method in the onChange method. Looks like setAttributes is similar to setState in React and makes the plugin UI to refresh and to reload my TestControl.
When TestControl reloads my optionsfiltered.filter works and the array get filtered according the selection.

Plupload file error 5 mb

I am using the plupload queue widget but it won't work.
Everytime i tries to upload a file larger than 5 mb it went to 100% and gives me a http Error.
When i upload a file from 3 mb this wil work perfectly and after 100% he gives me a green ok sign.
$(function () {
$("#uploader").pluploadQueue({
runtimes: 'html5,html4,flash,gears,silverlight,browserplus',
url: '/Upload/Upload',
max_file_size: '10mb',
post_max_size: '10mb',
upload_max_filesize: '10mb',
chunk_size: '10mb',
unique_names: true,
urlstream_upload:true,
multipart: true,
multiple_queues: false,
filters: [
{title: "Foto's", extensions: "jpg,gif,png"},
{title: "Video's", extensions: "wmv,avi" },
{ title: "Microsoft Office", extensions: "docx,xslx" },
{ title: "Zip files", extensions: "zip" },
],
preinit: {
FileUploaded: function (up, file, response) {
var data = response.response; //$.parseJSON(response.response);
$('<input>').attr({
type: 'hidden',
name: 'fileId' + data,
value: data
}).appendTo('#uploadFinishedForm');
if (data.error == 1) {
uploader.trigger("Error", { message: "'" + data.message + "'", file: file });
console.log('[Error] ' + file.id + ' : ' + data.message);
return false;
}
},
UploadComplete: function (up, files) {
window.setTimeout(function (form) {
// $('#uploadFinishedForm').submit();
$('.nextButton').append('<input type="submit" class="btn btn-large btn-success submit-btn" value="Transfer" />');
}, 2000)
},
Init: function (up, info) {
$('#uploader_container').removeAttr("title");
}
}
});
$('#uploadForm').submit(function (e) {
var uploader = $('#uploader').pluploadQueue();
if (uploader.files.length > 0) {
uploader.bind('StateChanged', function () {
if (uploader.files.length === (uploader.total.uploaded + uploader.total.failed)) {
$('#uploadForm').submit();
}
});
uploader.start();
} else {
$('#uploadInfo').html('Zonder foto\'s valt er niets te uploaden!');
}
return false;
});
Try to decrease the value of the chunk_size (1mb instead of 10mb by example):
chunk_size: '1mb'

jqgrid edit call ajax every time

I'm trying to use jqgrid edit form, but I can't understand why jqgrid do not call asmx web method every time I select a row and I click on edit icon (jqgrid call ajax just the first time)
This is the code:
function Grid() {
var ret = Array();
var grid = jQuery("#grid");
var hideLoading = function () {
$("#lui_" + grid).hide();
$("#load_" + grid).hide();
}
var strSearch = "";
var strField = "";
var strOper = "";
//
// handler: si occupa di creare il contenuto del menu a tendina (form jqGrid)
//
var buildOptions = function (dataList) {
var response = dataList;
var option = "";
if (response && response.length) {
for (var i = 0, l = response.length; i < l; i++) {
if (response[i]["selectedvalue"] == "on")
option += '<option role="option" selected="selected" value="' + response[i]["Codice"] + '">' + response[i]["Descrizione"] + '</option>';
else
option += '<option role="option" value="' + response[i]["Codice"] + '">' + response[i]["Descrizione"] + '</option>';
}
}
return option;
};
grid.jqGrid({
// setup custom parameter names to pass to server
prmNames: {
search: "isSearch",
nd: null,
rows: "numRows",
page: "page",
sort: "sortField",
order: "sortOrder"
},
// add by default to avoid webmethod parameter conflicts
postData: {
searchString: '',
searchField: '',
searchOper: ''
},
// setup ajax call to webmethod
datatype: function (postdata) {
$.ajax({
url: '<%# ResolveUrl("~/Service/Domain/ServiceRoom.asmx/GetRoomRateDiscount") %>',
type: "POST",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(postdata),
dataType: "json",
success: function (data, st) {
if (data.d == "KO") {
grid.GridUnload();
jAlert("La ricerca non ha restituito alcun risultato", "Book2Guest");
return false;
}
if (st == "success") {
var grid = $("#grid")[0];
grid.addJSONData(JSON.parse(data.d));
ret = JSON.parse(data.d);
}
},
error: function (xhr, textStatus, errorThrown) {
jAlert("Si รจ verificato un errore: " + textStatus + " " + errorThrown + " -- " + $.parseJSON(xhr.statusText), "Book2Guest");
}
});
},
// this is what jqGrid is looking for in json callback
jsonReader: {
root: "rows",
page: "page",
total: "totalpages",
records: "totalrecords",
cell: "cell",
id: "id",
userdata: "userdata",
repeatitems: true
},
ajaxSelectOptions: {
contentType: "application/json; charset=utf-8",
dataType: "json",
cache: false,
data: {
rowId: function () {
if (JSON.stringify(grid.jqGrid('getRowData', grid.jqGrid('getGridParam', 'selrow'))['Codice']) == undefined)
return "";
return JSON.stringify(grid.jqGrid('getRowData', grid.jqGrid('getGridParam', 'selrow'))['Codice']);
}
}
},
colNames: ['ID', 'Rate'],
colModel: [
{ name: 'ID', index: 'ID', width: 10, align: "center", search: false, sorttype: 'int', searchoptions: { sopt: ['eq', 'ne', 'cn']} },
{
name: 'TariffaCodiceOfferta',
index: 'TariffaCodiceOfferta',
width: 50,
hidden: true,
formatter: 'select',
editable: true,
edittype: 'select',
editrules: { edithidden: true }, //, required: true },
editoptions: {
multiselect: true,
dataUrl: '<%# ResolveUrl("~/Service/Domain/ServiceRoom.asmx/GetRoomRateListByRowId") %>',
buildSelect: function (data) {
var response = $.parseJSON(data.d);
var option = buildOptions(response);
var s = '<select>';
s += option;
return s + "</select>";
},
dataInit: function (elem) {
setTimeout(function () {
$(elem).multiselect({ selectedList: 10 });
}, 50);
},
multiple: true
}
},
],
rowNum: 10,
rowList: [10, 20, 30],
height: 'auto',
pager: '#gridpager',
viewrecords: true,
shrinkToFit: false,
loadComplete: function () {
hideLoading();
},
loadError: function () {
hideLoading();
},
editurl: '<%# ResolveUrl("~/Service/Domain/ServiceRoom.asmx/SaveRoomDiscount") %>',
sortname: "ID",
sortorder: "asc",
caption: "Rate list",
onSelectRow: function (id, status) {},
ondblClickRow: function (rowid) {
grid.jqGrid('editGridRow', rowid,
{
width: 450,
height: 450,
closeOnEscape: true,
addCaption: "Add Rate",
editCaption: "Edit Rate",
bSubmit: "Salva",
bCancel: "Annulla",
bClose: "Chiudi",
bYes: "Si",
bNo: "No",
bExit: "Annulla",
editData: {
"codice": function () {
var selectedRow = grid.getGridParam("selrow");
var rowData = grid.getRowData(selectedRow);
return rowData["Codice"];
}
},
viewPagerButtons: false,
closeAfterEdit: true,
reloadAfterSubmit: true,
beforeShowForm: function (form) {
var dlgDiv = $("#editmod" + grid[0].id);
var parentDiv = dlgDiv.parent(); // div#gbox_list
var dlgWidth = dlgDiv.width();
var parentWidth = parentDiv.width();
var dlgHeight = dlgDiv.height();
var parentHeight = parentDiv.height();
// Grabbed jQuery for grabbing offsets from here:
//http://stackoverflow.com/questions/3170902/select-text-and-then-calculate-its-distance-from-top-with-javascript
var parentTop = parentDiv.offset().top;
var parentLeft = parentDiv.offset().left;
dlgDiv[0].style.top = Math.round(parentTop + (parentHeight - dlgHeight) / 2) + "px";
dlgDiv[0].style.left = Math.round(parentLeft + (parentWidth - dlgWidth) / 2) + "px";
},
onClose: function (response, postdata) {
}
});
return;
},
gridComplete: function () {
if (grid.getGridParam('records') == 0) // are there any records?
DisplayEmptyText(true);
else
DisplayEmptyText(false);
},
emptyDataText: 'There are no records. '
})
grid.setGridWidth(900, true);
grid.jqGrid('navGrid', '#gridpager',
{
edit: true,
view: false,
add: false,
del: true,
search: false
},
//prmEdit
{
width: 450,
height: 300,
closeOnEscape: true,
addCaption: "Aggiungi Offerta",
editCaption: "Modifica Offerta",
bSubmit: "Salva",
bCancel: "Annulla",
bClose: "Chiudi",
saveData: "Sono state apportate delle modifiche, sei sicuro di voler continuare?",
bYes: "Si",
bNo: "No",
bExit: "Annulla",
editData: {
"Codice": function () {
var selectedRow = grid.getGridParam("selrow");
var rowData = grid.getRowData(selectedRow);
return rowData["Codice"];
}
},
viewPagerButtons: false,
closeAfterEdit: true,
reloadAfterSubmit: true,
beforeShowForm: function (form) {
var dlgDiv = $("#editmod" + grid[0].id);
var parentDiv = dlgDiv.parent(); // div#gbox_list
var dlgWidth = dlgDiv.width();
var parentWidth = parentDiv.width();
var dlgHeight = dlgDiv.height();
var parentHeight = parentDiv.height();
// Grabbed jQuery for grabbing offsets from here:
//http://stackoverflow.com/questions/3170902/select-text-and-then-calculate-its-distance-from-top-with-javascript
var parentTop = parentDiv.offset().top;
var parentLeft = parentDiv.offset().left;
dlgDiv[0].style.top = Math.round(parentTop + (parentHeight - dlgHeight) / 2) + "px";
dlgDiv[0].style.left = Math.round(parentLeft + (parentWidth - dlgWidth) / 2) + "px";
},
onClose: function (response, postdata) {}
}
//prmSearch,
//prmView
);
return ret;
}
UPDATE: to solve this issue, you guys have to insert 'recreateForm: true' in the edit section of jqGrid
You current code don't have 'Codice' column in colModel, but you try to get the data from the column. Even if the original server response has the Codice property, the property will be saved only if you add additional hidden column with the same name.
Sorry, but to tell the trust I would recommend you to rewrite the whole code which you use. The usage of datatype as function is not good. Instead of that you can use jsonReader. The call JSON.parse(data.d) inside of $.ajax having dataType: "json" shows that you did one more important error in the webmethod on the server side. It shows that you make manual conversion of returned object to String instead of returning object from the web method. WebService convert the object to JSON automatically. Because of manual convention to JSON the returned data will be twice converted to JSON. Only because of the error in the server code you have to use JSON.parse(data.d) and can't just use jsonReader like described here for example.

Resources