//example data for events
[
{
"jobId": 0,
"eventId": 79,
"title": "<b>2018-07-31 00029 Markosy Postal S.A.<\/b><br><span class='eventComment'>asfdasfsd<\/span>",
"start": "\/Date(1533542400000)\/",
"end": "\/Date(1533551400000)\/",
"color": "#FFCC00"
},
{
"jobId": 0,
"eventId": 80,
"title": "<b>2018-07-31 00029 Markosy Postal S.A.<\/b><br><span class='eventComment'>sfsdgs<\/span>",
"start": "\/Date(1533637800000)\/",
"end": "\/Date(1533646800000)\/",
"color": "#FFCC00"
},
{
"jobId": 0,
"eventId": 81,
"title": "<b>2018-07-31 00029 Markosy Postal S.A.<\/b><br><span class='eventComment'>dfdf s ddfsda ds fds 2222<\/span>",
"start": "\/Date(1533722400000)\/",
"end": "\/Date(1533727800000)\/",
"color": "#FFCC00"
},
{
"jobId": 0,
"eventId": 84,
"title": "<b>2018-07-31 00029 Markosy Postal S.A.<\/b><br><span class='eventComment'>gdgdfgsd<\/span>",
"start": "\/Date(1533808800000)\/",
"end": "\/Date(1533812400000)\/",
"color": "#FFCC00"
}
]
$('#calendar').fullCalendar({
locale: 'pl',
defaultView: 'agendaWeek',
header: {
left: 'prev,next today',
center: 'title',
right: 'agendaDay,agendaWeek,month,listWeek,year'
},
height: 'auto',
footer: false,
weekends: false,
slotEventOverlap: false,
timezone: 'local',
editable: true,
selectable: true,
events: {
url: '#Url.Action("GetGraphicCalendarEvents", "Schedule")',
textColor: 'black'
},
eventRender: function (event, element, view) {
var title = element.find('.fc-title, .fc-list-item-title');
title.html(title.text());
},
eventDrop: function (event) {
updateEventDate(event);
},
eventResize: function (event) {
updateEventDate(event);
},
select: function (startDate, endDate) {
$.ajax({
url: "#Url.Action("GraphicCalendarAddView", "Schedule")",
type: "post",
data: {
orderId: $("#OrderId").val(),
start: startDate.format("YYYY-MM-DD HH:mm:ss"),
end: endDate.format("YYYY-MM-DD HH:mm:ss")
},
success: function (result) {
if (result.hasOwnProperty("Success") && !result.Success) {
//error
} else {
//success
}
},
error: function (jqXHR, status, err) {
//error
}
});
},
eventClick: function (event) {
updateEventView(event);
}
});
I have a problem with FullCalendar https://fullcalendar.io/docs, I add some screenshot to explain my problem, When i click the button to show my calendar, but I only see not properly loaded events in calendar and when I click on any buttons of drag this thin strips it get fixed and calendar show everything properly.
I found the solution , the modal is not rendered, when the calendar is being rendered, I must add some delay.
example code: https://codepen.io/anon/pen/WKPyEN?editors=0010
$(function() {
$(".graphicPlanninngLetter").on("click", function() {
openCalendarWithView("GraphicPlanning");
});
function openCalendarWithView(action) {
showPopup("Test", "<div id='calendar'></div>");
setTimeout(function() {
$('#calendar').fullCalendar({
locale: 'pl',
defaultView: 'agendaWeek',
header: {
left: 'prev,next today',
center: 'title',
right: 'agendaDay,agendaWeek,month,listWeek,year'
},
allDaySlot: false,
height: 'auto',
footer: false,
weekends: false,
slotEventOverlap: false,
timezone: 'local',
editable: true,
selectable: true,
events: 'https://fullcalendar.io/demo-events.json',
eventRender: function (event, element, view) {
var title = element.find('.fc-title, .fc-list-item-title');
title.html(title.text());
},
});
}, 300)
}
function showPopup(title, content, button, selector) {
if (selector == undefined)
selector = "#popup";
$(selector + " .popupTitle").html(title);
$(selector + " .popupBody").html(content);
$(selector + " .popupButtons .additionalButtons").empty().append(button);
$(selector).modal("show");
}
});
Related
I am trying to add a button align to left side in the toolbar of my datatable.
In the rigth side I have 5 button for export.
I am newbie with Datatables and I am not an expertise with javascript, so If someone can help me I apreciate.
$(document).ready(function () {
var table = $('#TableId').DataTable(
{
columnDefs: [
{ "width": "5%", "targets": [0] },
{ "className": "text-left custom-middle-align", "targets": [0, 1, 2, 3, 4, 5, 6, 7] }
],
dom: '<"html5buttons"B>lTfgitp',
buttons: [
{extend: 'copy'},
{extend: 'csv'},
{extend: 'excel', title: 'ExampleFile'},
{extend: 'pdf', title: 'ExampleFile'},
{extend: 'print',
customize: function (win){
$(win.document.body).addClass('white-bg');
$(win.document.body).css('font-size', '10px');
$(win.document.body).find('table')
.addClass('compact')
.css('font-size', 'inherit');
}
}
],
processing: true,
serverSide: true,
ajax:
{
url: "/Plugin/GetData",
type: "POST",
dataType: "JSON"
},
rowId: "Sr",
columns: [
{
"className": 'details-control sorting_disabled',
"orderable": false,
"data": null,
"defaultContent": ''
},
{ "data": "Sr" },
{ "data": "OrderTrackNumber" },
{ "data": "Quantity" },
{ "data": "ProductName" },
{ "data": "SpecialOffer" },
{ "data": "UnitPrice" },
{ "data": "UnitPriceDiscount" }
],
order: [[1, "asc"]]
});
I have this
And I want this
Thank in advance.
Best regards.
Jolynice
I have a jqGrid that loads all employees' data on page load. There is a select list for departments. On changing the selection on that select list, the department's data is retrieved but it reloads the same all employees data again instead of the filtered data. How can I fix this?
$(function () {
jQuery("#jQGridDemo").jqGrid({
url: 'EmployeeTransfer.aspx/getEmployeesOnLoad',
datatype: 'json',
mtype: 'POST',
colNames: ['Project Name', 'Project Code', 'Emp Code', 'Emp Name', 'Department', 'Designation', 'Stage', 'Id'],
colModel: [
{ name: 'ProjectName', index: 'ProjectName', width: 90, stype: 'text', sorttype: 'string', search: true },
{ name: 'CompCode', index: 'CompCode', width: 90 },
{ name: 'FullCode', index: 'FullCode', width: 100, sorttype: 'integer', search: true },
{ name: 'EmpName', index: 'EmpName', width: 260, sorttype: 'string', search: true },
{ name: 'department', index: 'department', width: 270, hidden: true },
{ name: 'designation', index: 'designation', width: 260, sorttype: 'string', search: true },
{ name: 'Stage', index: 'Stage', width: 260 },
{ name: 'Id', index: 'Id', key: true, width: 70, sorttype: "int",hidden:true },
],
search: true,
rowNum: 30,
height: 700,
sortname: 'Id',
rownumbers: true,
sortable: true,
gridview: true,
loadonce: true,
pager: '#jQGridDemoPager',
viewrecords: true,
autoencode: true,
multiselect: true,
sortorder: "asc",
caption: "Employee Details",
onSelectRow: function (ids) {
if (jQuery("#jQGridDemo").jqGrid('getGridParam', 'records') > 0)
{
var rowId = $("#jQGridDemo").jqGrid('getGridParam', 'selrow');
var rowData = jQuery("#jQGridDemo").getRowData(rowId);
var colData = rowData['EmpName'];
jQuery("#jQGridSelect").addRowData(rowId, rowData);
}
},
serializeGridData: function (data) {
return $.toJSON(data);
}
}).jqGrid('hideCol', 'cb');
$("select#ddlDepts").change(function () {
var dept = $(this).find(":selected").text().trim();
$.ajax ({
type: "POST",
url: "EmployeeTransfer.aspx/getEmployeesByDept",
data: JSON.stringify({ strParam: dept}),
contentType: "application/json;charset=utf-8",
dataType: "json",
async: true,
cache: false,
success: function (data) {
if (data != null) {
jQuery('#jQGridDemo').jqGrid('clearGridData')
.jqGrid('setGridParam', { data: data, datatype: 'json' })
.trigger("reloadGrid", [{ current: true }]);
}
},
error:
function (x, e) {
alert("The call to the server side failed. " + x.responseText);
}
});
});
});
You need to add a postData param when configuring jqGrid e.g.:
jQuery("#jQGridDemo").jqGrid({ postData: { id: 1 } });
This id param would be posted to the server. Then in your callback from the ajax request, you can update the postData value e.g.:
jQuery('#jQGridDemo').jqGrid('clearGridData')
.jqGrid('setGridParam', { postData: { id: data.id } })
.trigger("reloadGrid", [{ current: true }]);
Finally, I was able to solve my problem. For anyone struggling like me, below is the working code.
success: function (data) {
if (data != null) {
$('#jQGridDemo').clearGridData(true);
$('#jQGridDemo').setGridParam({
datastr: data.d,
datatype: 'jsonstring',
rowNum: data.d.length
}).trigger('reloadGrid');
}
},
The format of my json string was as follows:
{
"d": {
"page": 0,
"total": 2,
"record": 2,
"rows": [
{
"id": 1,
"cell": [
" XXXX",
"107",
"902000707",
"XXXXXXXX",
"IT",
"SOFTWARE ENGINEER",
"Transfer 107 to 109",
"1"
]
},
{
"id": 2,
"cell": [
"XXXX",
"108",
"902000164",
"XXXXXXXX",
"IT",
"IT ADMINISTRATOR",
"Transfer 108 to 107",
"2"
]
}
],
"SortColumn": null,
"SortOrder": null
}
}
<script type="text/javascript">
$.jgrid.no_legacy_api = true;
$.jgrid.useJSON = true;
$(document).ready(function () {
jQuery("#tOceanC_ds_list").jqGrid({
// add by default to avoid webmethod parameter conflicts
// add by default to avoid webmethod parameter conflicts
url: "Default.aspx?cmd=select",
datatype: "json",
colNames: ['BOQID', 'BOQType', 'Description', 'Quantity'],
colModel:[
{ name: "BOQID", hidden: true, index: "BOQID", jsonmap: "BOQID",search:true,key:true,editable:true },
{ name: "BOQType", summaryTpl: "{0}", editable: true, searchoptions: {}, index: "BOQType", width: 200, align: "center", jsonmap: "BOQType", searchoptions: {}},
//{ name: "Description", editable: true, index: "Description", width: 200, align: "center", jsonmap: "Description", search: true },
{ "editoptions": { dataInit: function (el) { setTimeout(function () { var ec = 'DatePicker1'; if (typeof (jQuery(el).datepicker) !== 'function') alert('JQDatePicker javascript not present on the page. Please, include jquery.jqDatePicker.min.js'); jQuery(el).datepicker(eval(ec + '_dpid')); }, 200); } }, "summaryTpl": "{0}", "editable": true, "edittype": "text", "searchoptions": { dataInit: function (el) { setTimeout(function () { var ec = 'DatePicker1'; if (typeof (jQuery(el).datepicker) !== 'function') alert('JQDatePicker javascript not present on the page. Please, include jquery.jqDatePicker.min.js'); jQuery(el).datepicker(eval(ec + '_dpid')); }, 200); } }, name: "Description", index: "Description" },
{ name: "Quantity", editable: true, index: "Quantity", width: 200, align: "center", jsonmap: "Quantity", search: true }
],
viewrecords: true, scrollrows: false, postBackUrl: "__doPostBack('#tOceanC_ds_list','jqGridParams')",
editDialogOptions: { editCaption: "Edit Dialog", resize: false, closeAfterEdit: true, processData: "Default.aspx", bSubmit: "Submit", bCancel: "Cancel Editing", modal: true, recreateForm: true, errorTextFormat: function (data) { return 'Error: ' + data.responseText } },
addDialogOptions: { recreateForm: true, errorTextFormat: function (data) { return 'Error: ' + data.responseText } },
delDialogOptions: { errorTextFormat: function (data) { return 'Error: ' + data.responseText } },
searchDialogOptions: {left:300,top:400,resize:false},viewRowDetailsDialogOptions: {},jsonReader: { id: "BOQID" },
rowNum: 10,
height: "60%",
rownumbers: true,
autowidth: true,
shrinkToFit: false,
rowList:[10,20,30,50,100],
pager: jQuery("#OceanC_pager"),
viewrecords: true,
multiselect: false,
sortorder: "desc",
caption:"List of Users",
editurl: "Default.aspx",
//serializeGridData: function (data) {
// return $.toJSON(data);
//},
jsonReader: { repeatitems : false, id: "0" }
});
jQuery("#tOceanC_ds_list").jqGrid("navGrid", "#OceanC_pager", { add: false, edit: true, del: true, search: true, view: true,reload:true}, {}, {}, {}, { multipleSearch: false }, jQuery('#tOceanC_ds_list').getGridParam('editDialogOptions'), jQuery('#tOceanC_ds_list').getGridParam('addDialogOptions'), jQuery('#tOceanC_ds_list').getGridParam('delDialogOptions'), jQuery('#tOceanC_ds_list').getGridParam('searchDialogOptions'), jQuery('#tOceanC_ds_list').getGridParam('viewRowDetailsDialogOptions')).bindKeys()
});
function customPhoto(cellVal, options, rowObject){
return "<img src='assets/img/" + cellVal + "' height='50' width='50' >";
}
</script>
The editurl don't pass the parameter to edit the data like oper, del, edit, add
I want editurl to pass these parameter to code behind when I request.querystring["oper"] it return the empty or request.querystring["del"] it return empty
I am using asp.net webform 3.5 framework
I have implemented fullcalendar and it is working fine apart from 2 issues (I'll raise the second one in another question).
I can't add an image as I don't have the reputation! So to explain what I mean, I have an event that runs from 10am, July 3rd to 10am July 5th. When viewed by month it only displays on the 3rd July and does not span the 4th or 5th.
Here is my implementation code;
$('#calendar').fullCalendar({
events:function(start, end, callback) {
$.ajax({
type: "POST",
url: 'webservices/wsEvents.asmx/GetEventsBetweenDates',
contentType: "application/json",
dataType: "json",
data: formatCalendarDates(start, end),
success: function (doc) {
var events = [];
$.each(doc.d, function() {
var duration = GetDuration($(this).attr('StartTime'), $(this).attr('EndTime'), true);
var allday = moment.duration(moment($(this).attr('EndTime'))-moment($(this).attr('StartTime'))).days() >=1 ? true : false;
// duration.toLowerCase().indexOf("day") >= 0 ? true : false;
events.push({
title: replaceCharacter($(this).attr('Title'), "/u0027", "'"),
start: $(this).attr('StartTime'),
id: $(this).attr('ID'),
description: replaceCharacter($(this).attr('Description'),"/u0027","'"),
allDay: allday,
locationID: $(this).attr('Location'),
location: replaceCharacter($(this).attr('LocationName'), "/u0027", "'"),
duration: duration
});
});
callback(events);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
// debugger;
ShowError("Error: " + textStatus);
}
});
},
theme: true,
header: {
left: 'prevYear,prev,next,nextYear today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
buttonIcons:{
prevYear: "ui-icon ui-icon-triangle-1-w",
prev: "ui-icon ui-icon-carat-1-w",
next: "ui-icon ui-icon-carat-1-e",
nextYear: "ui-icon ui-icon-triangle-1-e"
},
editable: false,
allDaySlot: true,
allDayDefault: false,
firstDay: 1,
timeFormat: {
month: "H:mm",
week: "",
day: ""
},
weekNumbers: true,
weekNumberCalculation: "iso",
weekMode: "liquid",
weekNumberTitle: "Wk",
defaultView: "month",
firstHour: 0,
buttonText: {
today: 'today',
month: 'month',
week: 'week',
day: 'day'
},
columnFormat: {
month: 'ddd', // Mon
week: 'ddd d/M', // Mon 9/7
day: 'dddd d/M' // Monday 9/7
},
eventClick: function (date, allDay, jsEvent, view) {
DisplaySingleEvent(date, false)
},
eventMouseover: function (event, jsEvent, view) {
$(this).css('cursor', 'pointer')
},
eventMouseout: function (date, allDay, jsEvent, view) {
$(this).css('cursor', 'default')
},
eventRender: function (event, element) {
},
viewDisplay: function (view) {
}
});
Can anyone see from my code what I've done wrong?
Thanks
Terry.
Educated guess: specify end in the events array. You give duration but this is not a standard attribute according to the spec.
I am new to JQGrid, i am developing a screen where i need to use a tool bar in JQ Grid and perform search operation accordingly.
I have a date field in my JqGrid and i have added the DtPicker in the Search option also.
But when i select the date from DTPicker, search for the selected date is not performed.
Please let me know how to perform search for selected date.
<table id="test">
</table>
<div id="divtest">
</div>
<div>
<asp:Label ID="count" runat="server" Text="Label"></asp:Label>
</div>
<script type="text/javascript">
$(document).ready
(
function CreateGrid()
{
var lastSel,lastSel1, Status = ["All", "Active", "InActive"],defaultStatus="Active";
jQuery("#test").jqGrid
(
{
url:'Test.aspx',
datatype:'json',
contentType: "application/json; charset=utf-8",
jsonReader: {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false
},
colNames:[ 'EMPID',
'EMPName',
'DOB',
'Designation',
'Genders',
'Status',
'Remarks',
'EMPType',
''
],
colModel:
[
{
name:'EMPID',
index:'EMPID',
width:120,
sorttype:'int',
editable:false,
key:true,
sortable: true,
search:true,
editoptions:{readonly:true}
},
{
name:'EMPName',
index:'EMPName',
width:250,
sortable: true,
align:"left",
editable:true,
size:100,
editrule:{custom:true,custom_func:checkName}
},
{
name:'DOB',
index:'DOB',
width:250,
sortable: true,
align:"left",
size:100,
editable:true,
sorttype:"date",
formatter: "date",
formatoptions: {newformat:'m/d/Y'},
editrule:{custom:true,custom_func:checkName}
,editoptions:
{"dataInit":function(el)
{setTimeout(function(){if(jQuery.ui){
if(jQuery.ui.datepicker)
{
jQuery(el).datepicker({"disabled":false,
"dateFormat":"mm/dd/yy"
,changeMonth: true,
changeYear: true,
recreateForm: true});
jQuery('.ui-datepicker').css({'font-size':'69%'});
}
}},100);}
}
,searchoptions:
{"dataInit":function(el)
{setTimeout(function(){if(jQuery.ui) {
if(jQuery.ui.datepicker)
{
jQuery(el).datepicker({"disabled":false,
"dateFormat":"mm/dd/yy"
,changeMonth: true,
changeYear: true,
recreateForm: true});
jQuery('.ui-datepicker').css({'font-size':'69%'});
}
}},100);}
},
search:true
},
{
name:'Designation',
index:'Designation',
width:250,
align:"left",
editable:true,
size:100,
sortable: true,
formatter:'select',
edittype: 'select',
editoptions: {value:"0:select;1:CEO;2:HR;3:Manager;4:Team Lead;5:Software Engineer; 6:Tester;7:Sales;8:Others"}
,editrule:{custom:true,custom_func:checkDropDown}
,stype:'select',
searchoptions: {
sopt:['eq'],value:":All;1:CEO;2:HR;3:Manager;4:Team Lead;5:Software Engineer;6:Tester;7:Sales;8:Others"
}
},
{
name:'Gender',
index:'Gender',
width:150,
align: 'left',
editable:true,
size:100,
sortable: true,
formatter:'select',
edittype: 'select',
editoptions: {value: "0:select;1:Male;2:Female"},
editrule:{custom:true,custom_func:checkDropDown},
stype:'select',
searchoptions: {
sopt:['eq'],value:":All;1:Male;2:Female"
}
},
{
name:'Status',
index:'Status',
width:150,
align: 'left',
editable:true,
size:100,
sortable: true,
formatter:'select',
edittype: 'select',
editoptions: {value: "0:select;1:Active;2:InActive"}
,editrule:{custom:true,custom_func:checkDropDown},
stype:'select'
,searchoptions: {
sopt:['eq'],value:":All;1:Active;2:InActive"
}
},
{
name:'Remarks',
index:'Remarks',
width:150,
sortable: true,
align:"left",
editable:true,
edittype:"textarea",
editoptions:{rows:'3',cols:'10'},
size:100
},
{
name:'Emptype',
index:'Emptype',
sortable: true,
formatter:'checkbox',
editable:true,
edittype:"checkbox",
stype:'select',
searchoptions: {
sopt:['eq','ne'],value:":All;true:In;false:Out"
}
},
{
name:'action',
index: 'action',
sortable:false,
align:'center',
formatter:"actions",
formatoptions:{key:true},
search:false
}
],
rowNum:10,
rowList:[2,5,10,15],
pager:'#divtest',
viewrecords:true,
width:0.96*screen.width,height:0.42*screen.height,
caption:'jqGrid',
emptyrecords: "No Results Found",
sortable:true,
sortorder: "desc",
search:true,
ignoreCase:true,
loadonce:true,
multiselect: true,
shrinkToFit:true,forceFit:true
,editurl:"Test4.aspx",
onAfterSaveCell:
function reload(result)
{
$("#grid").trigger("reloadGrid");
}
,onSelectRow:
function (id)
{ var tr;
if (id && id !== lastSel)
{
if (typeof lastSel !== "undefined")
{
$("#test").jqGrid('restoreRow', lastSel);
$("#test").trigger("reloadGrid",[{current:true}]);
}
lastSel = id;
}
}
}
).jqGrid('navGrid','#divtest',
{ edit:false,
add:true,
del:false,
search:false
},
//for Edit
{
},
//for Add
{
top:0.20*screen.height,
left:(screen.width-(0.65*screen.width)),
width: 0.35*screen.width,
align:'Center',
resizeable: true,
closeAfterAdd:true,
reloadAfterSubmit:true,
serializeEditData: function(data)
{
return (data);
},
beforeShowForm: function(form)
{
$("#DOB").datepicker
({
changeMonth: true,
recreateForm: true,
changeYear: true
});
}
},
//for Delete
{
},
//for Search
{ multipleSearch: true,
multipleGroup:true,
//showQuery: true,
closeOnEscape: true,
closeAfterSearch: true,
overlay: 0,
beforeShowSearch:function()
{
$("#test")[0].toggleToolbar();
},
onClose: function()
{
$("#test")[0].toggleToolbar();
}
}
).jqGrid('navButtonAdd','#divtest',
{
caption:" ",
width:'15',
buttonicon:"ui-icon-search",
onClickButton: function()
{
$("#test")[0].toggleToolbar();
},
position:"last"
})
//For displaying the blank tool bar on the grid
.jqGrid('filterToolbar',
{
stringResult: true,
searchOnEnter: false,
defaultSearch: "cn"
}
)
.jqGrid('inlineNav',"#pager",{
edit:false,
editicon: "ui-icon-pencil",
add:true,
addicon:"ui-icon-plus",
cancel: true,
cancelicon:"ui-icon-cancel",
save: true,
saveicon:"ui-icon-disk"
}
);
//The Date DTPicker field in the Edit portion.
var initDateEdit =
function(elem)
{
setTimeout(function()
{
$(elem).datepicker(
{
dateFormat: 'mm/dd/yy',
autoSize: true,
//showOn: 'button',
changeYear: true,
changeMonth: true,
showButtonPanel: true,
recreateForm: true,
showWeek: true
});
},100);
}
,
//The Date DTPicker field in the Search portion.
//But not working in this.
initDateSearch =
function(elem)
{
setTimeout(function()
{
$(elem).datepicker(
{
dateFormat: 'mm/dd/yy',
autoSize: true,
//showOn: 'button',
changeYear: true,
changeMonth: true,
showButtonPanel: true,
recreateForm: true,
showWeek: true
});
},100);
}
;
//To hide the check box or select box in the Header of the JQGrid.
var myGrid = $("#test");
$("#cb_"+myGrid[0].id).hide();
var grid = $("#test"),
getColumnIndexByName = function (grid, columnName)
{
var cm = grid.jqGrid('getGridParam', 'colModel'), i, l = cm.length;
for (i = 0; i < l; i++)
{
if (cm[i].name === columnName)
{return i;}
}
return -1;
};
}
);
</script>
Thanks and Regards,
NMB
You just need to add this after your Filter tool bar..
.change(function(){$("#table_ID")[0].toggleToolbar()})