SyncFusion: Localize Gantt - localization

I'm trying to localize a the Gantt element. However I'm facing some problems.
I have taken a look to http://help.syncfusion.com/aspnet/gantt/localization
and write this code:
<div style="width:100%; height:800px;">
#(Html.EJ().Gantt("ganttsample")
.TaskIdMapping("TaskID")
.TaskNameMapping("TaskName")
.StartDateMapping("StartDate")
.EndDateMapping("EndDate")
.DurationMapping("Duration")
.ProgressMapping("Progress")
.ScheduleStartDate("01/01/2016")
.ScheduleEndDate("31/12/2016")
.DateFormat("dd/MM/yyyy")
.HighlightWeekends(true)
.TreeColumnIndex(1)
.ShowGridCellTooltip(true)
.ChildMapping("SubTasks")
.AllowSelection(true)
.AllowGanttChartEditing(true)
.PredecessorMapping("Predecessors")
.AllowColumnResize(true)
.AllowSorting(true)
.IncludeWeekend(false)
.ResourceInfoMapping("IdEstado")
.ResourceNameMapping("ResourceName")
.ResourceIdMapping("ResourceID")
.ShowResourceNames(true)
.EnableContextMenu(true)
.Locale("es-ES")
.EditSettings(edit =>
{
edit.AllowAdding(true);
edit.AllowDeleting(true);
edit.AllowEditing(true);
edit.EditMode("cellEditing");
})
.EnableResize(true)
.EnableVirtualization(false)
.ToolbarSettings(toolbar =>
{
toolbar.ShowToolbar(true);
toolbar.ToolbarItems(new List<GanttToolBarItems>()
{
GanttToolBarItems.Add,
GanttToolBarItems.Search,
GanttToolBarItems.Edit,
GanttToolBarItems.Delete,
GanttToolBarItems.Update,
GanttToolBarItems.Cancel,
GanttToolBarItems.Indent,
GanttToolBarItems.Outdent,
GanttToolBarItems.ExpandAll,
GanttToolBarItems.CollapseAll
});
})
.SizeSettings(ss => ss.Width("100%").Height("100%"))
.Resources(ViewBag.datasource1)
.Datasource(ViewBag.datasource)
)
</div>
<script type="text/javascript">
ej.Gantt.localization["es-ES"] = {
//headerText to be displayed in gridtree
columnHeaderTexts: {
taskId: "ID",
taskName: "Nombre",
startDate: "F. Inicio",
endDate: "F. Fin",
resourceInfo: "Otra Cosa",
duration: "Duración",
status: "Progreso",
predecessor: "Predecesor",
baselineStartDate: "F. Inicio Base",
baselineEndDate: "F.Fin Base"
},
//string to display in dialog
editDialogTexts: {
addFormTitle: "Nueva Tarea",
editFormTitle: "Editar tarea",
saveButton: "Guardar",
cancelButton: "Cancelar"
},
contextMenuTexts: {
taskDetailsText: "Detalle",
addNewTaskText: "Nueva tarea",
indentText: "Indexar >",
outdentText: "< Desindexar",
deleteText: "Eliminar",
aboveText: "Arriba",
belowText: "Abajo"
},
calendars: {
standard: {
firstDay: 1,
days: {
names: ["Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado"],
namesAbbr: ["Dom.", "Lun.", "Mar.", "Mié.", "Jue.", "Vie.", "Sáb."],
namesShort: ["D", "L", "M", "X", "J", "V", "S"]
},
months: {
names: ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre", ""],
namesAbbr: ["Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic", ""]
},
AM: null,
PM: null,
eras: [{ "name": "ap. J.-C.", "start": null, "offset": 0 }],
patterns: {
d: "dd/MM/yyyy",
D: "dddd d MMMM yyyy",
t: "HH:mm",
T: "HH:mm:ss",
f: "dddd d MMMM yyyy HH:mm",
F: "dddd d MMMM yyyy HH:mm:ss",
M: "d MMMM",
Y: "MMMM yyyy"
}
}
}
}
</script>
However, as you can see the image, the calendar cannot render:
Any ideas?

To render Syncfusion Gantt control for specific culture, make sure the following external and internal scripts and theme files have been referred.
<script src="#Url.Content("~/Scripts/jquery-2.1.4.min.js")"></script>
<script src="#Url.Content("~/Scripts/jsrender.min.js")"></script>
<script src="#Url.Content("~/Scripts/jquery.easing-1.3.min.js")"></script>
<script src="#Url.Content("~/Scripts/jquery.globalize.min.js")"></script>
<script src="#Url.Content("~/Scripts/ej.web.all.min.js")"></script>
<script src="#Url.Content("~/Scripts/cultures/ej.culture.es-ES.min.js")"></script>
Error: Cannot read property 'calendar' of null.
This error will occur only if you have missed to refer your following culture js file.
<script src="#Url.Content("~/Scripts/cultures/ej.culture.es-ES.min.js")"></script>
Refer this file and let me know if you face any other issues.
Hope this helps!

Related

Kendo Gantt Timeline in 30 minute increments?

I am using the Kendo Gantt chart with ASP.NET Core MVC, and I would like to get the Day view timeline to show in 30 minute increments vs. 1 hour increments. The working hours I'm trying to display for each day are 7:00 AM to 3:30 PM, but I cannot get that 3:30 PM end of day to display.
Here is an example of getting a time header template using the jquery kendo gantt chart
<div id="gantt"></div>
<script>
$("#gantt").kendoGantt({
dataSource: [{
id: 1,
orderId: 0,
parentId: null,
title: "Task1",
start: new Date("2014/6/17 9:00"),
end: new Date("2014/6/17 11:00")
}],
views: [
{ type: "day", timeHeaderTemplate: kendo.template("#=kendo.toString(start, 'T')#") },
{ type: "week" },
{ type: "month" }
]
});
</script>
However, I can't figure out how get that template to show the 30 minute increments, or if there is a different way to accomplish this. Essentially, I want it to look like the Kendo Scheduler Timeline view shown here:
I opened a support ticket with Telerik and got an answer that while there is no built-in way to do this with the Gantt component, one way to implement would be to create a custom view as demonstrated here: https://docs.telerik.com/kendo-ui/controls/scheduling/gantt/how-to/creating-custom-view
Custom view example code:
<div id="gantt"></div>
<script type="text/javascript">
var gantt;
$(function StartingPoint() {
kendo.ui.GanttCustomView = kendo.ui.GanttView.extend({
name: "custom",
options: {
yearHeaderTemplate: kendo.template("#=kendo.toString(start, 'yyyy')#"),
quarterHeaderTemplate: kendo.template("# return ['Q1', 'Q2', 'Q3', 'Q4'][start.getMonth() / 3] #"),
monthHeaderTemplate: kendo.template("#=kendo.toString(start, 'MMM')#")
},
range: function(range) {
this.start = new Date("01/01/2013");
this.end = new Date("01/01/2016");
},
_generateSlots: function(incrementCallback, span) {
var slots = [];
var slotStart = new Date(this.start);
var slotEnd;
while (slotStart < this.end) {
slotEnd = new Date(slotStart);
incrementCallback(slotEnd);
slots.push({ start: slotStart, end: slotEnd, span: span });
slotStart = slotEnd;
}
return slots;
},
_createSlots: function() {
var slots = [];
slots.push(this._generateSlots(function(date) { date.setFullYear(date.getFullYear() + 1); }, 12));
slots.push(this._generateSlots(function(date) { date.setMonth(date.getMonth() + 3); }, 3));
slots.push(this._generateSlots(function(date) { date.setMonth(date.getMonth() + 1); }, 1));
return slots;
},
_layout: function() {
var rows = [];
var options = this.options;
rows.push(this._slotHeaders(this._slots[0], kendo.template(options.yearHeaderTemplate)));
rows.push(this._slotHeaders(this._slots[1], kendo.template(options.quarterHeaderTemplate)));
rows.push(this._slotHeaders(this._slots[2], kendo.template(options.monthHeaderTemplate)));
return rows;
}
});
gantt = new kendo.ui.Gantt($("#gantt"),
$.extend({
columns: [
{ field: "id", title: "ID", sortable: true, editable: false, width: 30 },
{ field: "title", title: "Title", sortable: true, editable: true, width: 100 },
{ field: "start", title: "Start Time", sortable: true, editable: true, format: "{0:MM/dd/yyyy HH:mm}", width: 100 },
{ field: "end", title: "End Time", sortable: true, editable: true, format: "{0:MM/dd/yyyy HH:mm}", width: 100 }
],
views: [
"week",
{ type: "kendo.ui.GanttCustomView", title: "Quaterly", selected: true }
],
listWidth: 500,
dataBound: function() {
var height = this.timeline.view().header.height();
this.list.thead.find('tr').css('height',height);
},
dataSource: {
data: [{ id: 1, parentId: null, percentComplete: 0.2, orderId: 0, title: "foo", start: new Date("05/05/2014 09:00"), end: new Date("06/06/2014 10:00") },
{ id: 2, parentId: null, percentComplete: 0.4, orderId: 1, title: "bar", start: new Date("07/06/2014 12:00"), end: new Date("08/07/2014 13:00") }]
},
dependencies: {
data: [
{ id: 1, predecessorId: 1, successorId: 2, type: 1 }
]
}
}, {})
);
});
</script>

Error: cannot call methods on tabulator prior to initialization; attempted to call method 'addRow'

I have a page with a table:
<table id="myTable">
<thead>
<tr>
<th>Description</th>
<th>Qty</th>
<th>Cost</th>
</tr>
</thead>
<tbody>
#foreach (var item in Model)
{
#Html.EditorFor(model => item);
}
</tbody>
</table>
And I then initialise Tabular like so:
$("#myTable").tabulator({
layout: "fitColumns",
addRowPos: "bottom",
columns: [
{ title: "Description", field: "Description", editor: "input" },
{ title: "Qty", field: "Quantity", sorter: "number", editor: "number", editorParams: { min: 0, step: 1, } },
{ title: "Cost", field: "Cost", sorter: "number", editor: "number", editorParams: { min: 0, step: 0.1, }, align: "right", formatterParams: { decimal: '.', thousand: '.', symbol: "R" }, bottomCalc: "sum", bottomCalcFormatter: "money", bottomCalcFormatterParams: { decimal: '.', thousand: '.', symbol: "R" } },
{ formatter: "buttonCross", width: 30, align: "center", cellClick: function (e, cell) { cell.getRow().delete(); } },
],
});
This all works pretty nicely, but I attempted to add:
$("#add-row").click(function () {
$("#myTable").tabulator("addRow", {}, true);
});
clicking on my button to add a new row results in: Error: cannot call methods on tabulator prior to initialization; attempted to call method 'addRow'
I tried to do: var table = $("#myTable").tabulator... with table.addRow({}) but then I get an error saying addRow is not a function.
Is it supposed to work like this?
That message suggests that you havnt created your Tabulator object before you have called the addRow function.
If you are new to Tabulator then i would suggest that you dont use the jQuery wrapper. that was there more for legacy reasons from the old 3.5 version.
In this case you should use the constructor:
var table = new Tabulator("#myTable", {
layout: "fitColumns",
addRowPos: "bottom",
columns: [
{ title: "Description", field: "Description", editor: "input" },
{ title: "Qty", field: "Quantity", sorter: "number", editor: "number", editorParams: { min: 0, step: 1, } },
{ title: "Cost", field: "Cost", sorter: "number", editor: "number", editorParams: { min: 0, step: 0.1, }, align: "right", formatterParams: { decimal: '.', thousand: '.', symbol: "R" }, bottomCalc: "sum", bottomCalcFormatter: "money", bottomCalcFormatterParams: { decimal: '.', thousand: '.', symbol: "R" } },
{ formatter: "buttonCross", width: 30, align: "center", cellClick: function (e, cell) { cell.getRow().delete(); } },
],
});
And then you can add rows like this:
table.addRow({}, true);
You just need to make sure that when you assign it to the table variable it is in a scope where it can be accessed by all functions that need it
I was initialising a Tabulator onto an existing table targetting the <table id="myTable"> element. Although this works great initially, trying other stuff (like in my question) kept on resulting in 'Error: cannot call methods on tabulator prior to initialization'.
I ended up scraping the predefined <table> and went with initialising on <div id="myTable"> and getting the data via ajax.
Now it all works as expected/documented. Dunno if this is a bug/supposed to work like this/my own incompetence, but at least I can move on.

AngularJS: service $http.get JSON file

I am very new to AngularJS. I have read several posts on this topic, but am still unable to get data from external JSON file.
here is my code
data.json
[
{
"id": 1,
"date": "20th August 2016",
"day": "Sat",
"in1": "10:30",
"out1": "02:30",
"in2": "04:00",
"out2": "08:00",
"in3": "",
"out3": "",
"total_hours": "8:00",
"status": "1"
},
{
"id": 2,
"date": "20th August 2016",
"day": "Sat",
"in1": "10:30",
"out1": "02:30",
"in2": "04:00",
"out2": "08:00",
"in3": "",
"out3": "",
"total_hours": "8:00",
"status": "1"
}
];
html
<table ng-table="tctrl.tableEdit" class="table table-striped table-vmiddle">
<tr ng-repeat="w in $data" ng-class="{ 'active': w.$edit }">
<td data-title="'ID'">
<span ng-if="!w.$edit">{{ w.id }}</span>
<div ng-if="w.$edit"><input class="form-control" type="text" ng-model="w.id" /></div>
</td>
...
</tr>
</table>
controller.js
.controller('tableCtrl', function($filter, $sce, ngTableParams, tableService) {
var data = tableService.data;
//Editable
this.tableEdit = new ngTableParams({
page: 1, // show first page
count: 10 // count per page
}, {
total: data.length, // length of data
getData: function($defer, params) {
$defer.resolve(data.slice((params.page() - 1) * params.count(), params.page() * params.count()));
}
});
})
service.js
.service('tableService', [function($http){
this.data = function() {
return $http.get('data/timesheet.json');
}
}])
I'm just trying to pull data from json file but it's not working and getting blank table. I don't know what is the issue. What I will get in this.data?

FullCalendar not displaying in wanted timezone

Using fullCalendar I am not able to get it to display in a different timezone. I am in pacific timezone, but I want to see the events as if I was on New York. I have also tried to pass the dates in with the offset (2014-11-20T13:33:00-0800). No matter what, they display as pacific time zone. What am I doing wrong?
$(document).ready(function () {
var dt = "2014-11-20";
var tz = "America/New_York";
//Call the fullCallendar method. You can replace the '#calendar' with the ID of the dom element where you want the calendar to go.
$('#calendar').fullCalendar({
header: {
//left: 'prev,next today',
left: '',
center: 'title',
right: ''
//right: 'month,agendaWeek,agendaDay'
},
editable: false,
defaultDate: dt,
timezone: tz,
defaultView: 'agendaDay',
allDaySlot: false,
events: [
//At run time, this APEX Repeat will reneder the array elements for the events array
{
title: "New Photo Shoot",
start: '2014-11-20T13:27:00',
end: '2014-11-20T14:27:00',
url: '',
allDay: false,
className: 'event-personal'
}, {
title: "GMB/Calendar Test 4 - Initial Photo Shoot",
start: '2014-11-20T11:00:00',
end: '2014-11-20T13:00:00',
url: '/00UJ00000081xpZMAQ',
allDay: false,
className: 'event-birthday'
}, {
title: "GMB/Calendar Test 4 - Initial Photo Shoot",
start: '2014-11-20T10:36:00',
end: '2014-11-20T12:36:00',
url: '/00UJ00000081xptMAA',
allDay: false,
className: 'event-birthday'
}, ]
});
});

jQuery UI datepicker: How to change the month names in the drop-down from short to long names?

I need to change the month names from short names to long names in my jQuery UI datepicker.
My properties are:
$.datepicker.regional['de'] = {
prevText: '<zurück',
nextText: 'vor>',
monthNames: ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni',
'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'],
monthNamesShort: ['Jan', 'Feb', 'Mär', 'Apr', 'Mai', 'Jun',
'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez'],
dayNames: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'],
dayNamesShort: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
dayNamesMin: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
weekHeader: 'Wo',
dateFormat: 'dd.mm.yy',
firstDay: 1,
changeMonth: true,
changeYear: true,
yearRange: "-0:+2",
isRTL: false,
showMonthAfterYear: false,
minDate: 0
};
$.datepicker.setDefaults($.datepicker.regional['de']);
var dates = $("#von, #bis").datepicker({
showOn: "button",
buttonImage: "calendar.png",
buttonImageOnly: true,
buttonText: 'Datum w\u00E4hlen',
onSelect: function (selectedDate) {
var option = this.id == "#von" ? "minDate" : "maxDate",
instance = $(this).data("datepicker"),
date = $.datepicker.parseDate(
instance.settings.dateFormat ||
$.datepicker._defaults.dateFormat,
selectedDate, instance.settings);
dates.not(this).datepicker("option", option, date);
}
});
At the moment the calendar only shows short month names like "Apr" instead of "April" in the dropdown list.
Maybe I am overwriting the default long names with some piece of code?
Please help.
Use the property monthNamesShort and attribute it the names you want.
In my case, I wanted to show, in the month drop-down, the month long name, in portuguese:
monthNamesShort: [ "Janeiro", "Fevereiro", "Março", "Abril",
"Maio", "Junho", "Julho", "Agosto", "Setembro",
"Outubro", "Novembro", "Dezembro" ]
It's not possible at the moment. See https://github.com/jquery/jquery-ui/pull/590 for details.
In many places they use the dateFormat to determine which list to use. Unfortunately in this block of code they weren't consistent using it. I made an adjustment to follow their method in _generateMonthYearHeader (around line 8985):
replace
monthNamesShort[ month ]
with
(inst.settings.dateFormat.match(/MM/) ? monthNames : monthNamesShort)[ month ]

Resources