I'm getting Cannot call method 'getTime' of undefined error when I try to create a new event by clicking on Ext JS 4 calendar.
Here's my event store defition:
Ext.calendar.data.EventMappings = {
// These are the same fields as defined in the standard EventRecord object but the
// names and mappings have all been customized. Note that the name of each field
// definition object (e.g., 'EventId') should NOT be changed for the default fields
// as it is the key used to access the field data programmatically.
EventId: {name: 'id', mapping:'id', type:'int'}, // int by default
CalendarId: {name: 'cid', mapping: 'cid', type: 'int'}, // int by default
Title: {name: 'title', mapping: 'title'},
StartDate: {name: 'start', mapping: 'start', type: 'date', dateFormat: 'c'},
EndDate: {name: 'end', mapping: 'end', type: 'date', dateFormat: 'c'},
RRule: {name: 'recur_rule', mapping: 'recur_rule'},
Location: {name: 'loc', mapping: 'loc'},
Notes: {name: 'notes', mapping: 'notes'},
Url: {name: 'url', mapping: 'url', type : 'int' },
IsAllDay: {name: 'ad', mapping: 'ad', type: 'boolean'},
Reminder: {name: 'rem', mapping: 'rem'},
// We can also add some new fields that do not exist in the standard EventRecord:
CreatedBy: {name: 'collabUserId', mapping: 'collabUserId', type: 'int'}
};
// Don't forget to reconfigure!
Ext.calendar.data.EventModel.reconfigure();
Ext.define(appName + '.store.Events', {
extend : 'Ext.calendar.data.MemoryEventStore',
// model : appName + '.model.Event',
autoLoad : false,
autoSync : true,
proxy : {
type : 'ajax',
// url : 'randevu/loadEvents.ajax',
api : {
read : 'randevu/loadEvents.ajax',
create : 'randevu/saveOrUpdateEvent.ajax',
update : 'randevu/saveOrUpdateEvent.ajax',
destroy : 'randevu/deleteEvent.ajax'
},
reader : {
type : 'json',
root : 'data',
successProperty : 'success',
totalProperty : 'totalCount',
idProperty : 'id'
},
writer : {
type : 'json',
writeAllFields : true,
encode : true,
root : 'data'
}
}
});
And my Calendar view:
Ext.define(appName + '.view.randevu.RandevuPanel', {
extend : appName + '.view.base.BasePanel',
requires : [ 'Ext.calendar.util.Date',
'Ext.calendar.CalendarPanel',
'Ext.calendar.data.MemoryCalendarStore',
'Ext.calendar.data.MemoryEventStore',
'Ext.calendar.data.Events',
'Ext.calendar.data.Calendars',
'Ext.calendar.form.EventWindow',
appName + '.view.user.UserCombo'
],
alias : 'widget.randevupanel',
iconCls : 'icon-calendar',
width : '100%',
// titleAlign : 'center',
layout : {
type : 'hbox',
align : 'stretch'
},
defaults : { flex : 1 }, //auto stretch
initComponent: function() {
var me = this;
this.calendarStore = OnlineRandevuSistemi.app.getStore('Calendars');
this.eventStore = OnlineRandevuSistemi.app.getStore('Events');
this.updateTitle = function(startDt, endDt) {
var p = Ext.getCmp('app-center'),
fmt = Ext.Date.format;
if(Ext.Date.clearTime(startDt).getTime() == Ext.Date.clearTime(endDt).getTime()){
p.setTitle(fmt(startDt, 'F j, Y'));
}
else if(startDt.getFullYear() == endDt.getFullYear()){
if(startDt.getMonth() == endDt.getMonth()){
p.setTitle(fmt(startDt, 'F j') + ' - ' + fmt(endDt, 'j, Y'));
}
else{
p.setTitle(fmt(startDt, 'F j') + ' - ' + fmt(endDt, 'F j, Y'));
}
}
else{
p.setTitle(fmt(startDt, 'F j, Y') + ' - ' + fmt(endDt, 'F j, Y'));
}
};
this.showEditWindow = function(rec, animateTarget){
console.log(rec);
if(!this.editWin){
this.editWin = Ext.create('Ext.calendar.form.EventWindow', {
calendarStore: this.calendarStore,
listeners: {
'eventadd': {
fn: function(win, rec){
win.hide();
rec.data.IsNew = false;
this.eventStore.add(rec);
// this.eventStore.sync();
this.showMsg('<b>'+ rec.data.Title +'</b> etkinliği eklendi.');
},
scope: this
},
'eventupdate': {
fn: function(win, rec){
win.hide();
rec.commit();
// this.eventStore.sync();
this.showMsg('<b>'+ rec.data.Title + '</b> etkinliği düzenlendi.');
},
scope: this
},
'eventdelete': {
fn: function(win, rec){
this.eventStore.remove(rec);
// this.eventStore.sync();
win.hide();
this.showMsg('<b>'+ rec.data.Title +'</b> etkinliği silindi.');
},
scope: this
},
'editdetails': {
fn: function(win, rec){
win.hide();
Ext.getCmp('app-calendar').showEditForm(rec);
}
}
}
});
}
this.editWin.show(rec, animateTarget);
};
this.showMsg = function(msg){
Ext.example.msg('Bilgilendirme', msg);
// Ext.fly('app-msg').update(msg).removeCls('x-hidden');
};
this.clearMsg = function(){
Ext.fly('app-msg').update('').addCls('x-hidden');
};
this.title = bundle.getMsg('randevupanel.title');
this.items = [{
id: 'app-center',
title: '...', // will be updated to the current view's date range
titleAlign : 'center',
region: 'center',
layout: 'border',
listeners: {
'afterrender': function(){
Ext.getCmp('app-center').header.addCls('app-center-header');
}
},
items: [{
xtype: 'container',
id:'app-west',
region: 'west',
width: Ext.themeName === 'neptune' ? 214 : 179,
items: [{
xtype: 'datepicker',
id: 'app-nav-picker',
cls: 'ext-cal-nav-picker',
listeners: {
'select': {
fn: function(dp, dt){
Ext.getCmp('app-calendar').setStartDate(dt);
},
scope: this
}
}
}]
},{
xtype: 'calendarpanel',
eventStore: this.eventStore,
// eventStore: 'Events',
calendarStore: this.calendarStore,
border: false,
id:'app-calendar',
region: 'center',
activeItem: 3, // month view
monthViewCfg: {
showHeader: true,
showWeekLinks: true,
showWeekNumbers: true
},
listeners: {
'eventclick': {
fn: function(vw, rec, el){
this.showEditWindow(rec, el);
this.clearMsg();
},
scope: this
},
'eventover': function(vw, rec, el){
//console.log('Entered evt rec='+rec.data.Title+', view='+ vw.id +', el='+el.id);
},
'eventout': function(vw, rec, el){
//console.log('Leaving evt rec='+rec.data.Title+', view='+ vw.id +', el='+el.id);
},
'eventadd': {
fn: function(cp, rec){
this.showMsg('Event '+ rec.data.Title +' was added');
},
scope: this
},
'eventupdate': {
fn: function(cp, rec){
this.showMsg('Event '+ rec.data.Title +' was updated');
},
scope: this
},
'eventcancel': {
fn: function(cp, rec){
// edit canceled
},
scope: this
},
'viewchange': {
fn: function(p, vw, dateInfo){
if(this.editWin){
this.editWin.hide();
}
if(dateInfo){
// will be null when switching to the event edit form so ignore
Ext.getCmp('app-nav-picker').setValue(dateInfo.activeDate);
this.updateTitle(dateInfo.viewStart, dateInfo.viewEnd);
}
},
scope: this
},
'dayclick': {
fn: function(vw, dt, ad, el){
this.showEditWindow({
StartDate: dt,
IsAllDay: ad
}, el);
this.clearMsg();
},
scope: this
},
'rangeselect': {
fn: function(win, dates, onComplete){
this.showEditWindow(dates);
this.editWin.on('hide', onComplete, this, {single:true});
this.clearMsg();
},
scope: this
},
'eventmove': {
fn: function(vw, rec){
var mappings = Ext.calendar.data.EventMappings,
time = rec.data[mappings.IsAllDay.name] ? '' : ' \\a\\t g:i a';
rec.commit();
this.showMsg('Event '+ rec.data[mappings.Title.name] +' was moved to '+
Ext.Date.format(rec.data[mappings.StartDate.name], ('F jS'+time)));
this.eventStore.sync();
},
scope: this
},
'eventresize': {
fn: function(vw, rec){
rec.commit();
this.showMsg('Event '+ rec.data.Title +' was updated');
},
scope: this
},
'eventdelete': {
fn: function(win, rec){
this.eventStore.remove(rec);
this.showMsg('Event '+ rec.data.Title +' was deleted');
},
scope: this
},
'initdrag': {
fn: function(vw){
if(this.editWin && this.editWin.isVisible()){
this.editWin.hide();
}
},
scope: this
}
}
}]
}];
this.scdUserLabel = Ext.create('Ext.form.DisplayField', {
hideLabel : true,
value : 'Misafir Oturumu'
});
this.btnLogin = Ext.create('Ext.Button', {
text : bundle.getMsg('randevupanel.btnLogin.text'),
iconCls : 'icon-sign-in',
action : 'login',
tooltip : bundle.getMsg('randevupanel.btnLogin.tip')
});
this.btnLogout = Ext.create('Ext.Button', {
text : bundle.getMsg('randevupanel.btnLogout.text'),
iconCls : 'icon-sign-out',
action : 'logout',
hidden : true,
tooltip : bundle.getMsg('randevupanel.btnLogout.tip')
});
this.tbar = Ext.create('Ext.Toolbar', {
items : [ ' ', me.scdUserLabel, '->', me.btnLogin, me.btnLogout ]
});
this.callParent(arguments);
}
});
Related
I am having a hierarchical nested Kendo grid. The parent grid is displaying a list of currency and each currency has a list of allocation. Both grid have a inline editor. Currency has a property 'currencyName' and allocation has a property 'allocationName'. Both these property need to have a kendo dropdownlist editor.
In my solution, I am able to get the drop down for the currencyName, but for allocationName I am getting a textbox. Below is the code:
HTML :
<div kendo-grid="ctrl.currencyKendoGrid" style="margin-top: 2em" k-options="ctrl.currencyGridOptions"></div>
Currency Grid DataSource:
This is being assigned by another parent funds grid. The funds grid has an editable pop-up window, and assigns the currencyKendoGrid it's data source on the edit event as follows.
edit: function (e) {
if (e.model.currencies)
ctrl.currencyKendoGrid.dataSource.data(e.model.currencies);
}
Currency DropDown DataSource:
ctrl.currencyDataSource = new kendo.data.DataSource({
type: "json",
transport: {
read: function (e) {
DataSvc.getCurrencyData().then(function (response) {
e.success(response.data);
});
}
}
});
Allocation DropDown DataSource:
ctrl.allocationsList = [{ allocName: "Cash", allocId: 1 }, { allocName: "Money Market", allocId: 2 }, { allocName: "TBill", allocId: 3 }, { allocName: "FX-Forward", allocId: 4 }];
ctrl.allocationDataSource = new kendo.data.DataSource({
type: "json",
transport: {
read: function (e) {
e.success(ctrl.allocationsList);
}
}
});
Currency Grid Options:
ctrl.currencyGridOptions = {
dataSource: {
schema: {
model: {
fields: {
currency: { type: "string", editable: true }
}
}
}
},
editable: "inline",
toolbar: [{
name: 'create',
text: 'Add Currency',
}],
columns: [
{
field: "currencyName", title: "Currency",
editor: function (container, options) {
$('<input kendo-drop-down-list required k-data-text-field="\'currencyName\'" k-data-value-field="\'currencyName\'" k-data-source="ctrl.currencyDataSource" data-bind="value:' + options.field + '"/>')
.appendTo(container);
}
},
{ command: [{ name: "edit", text: "" }, { name: "destroy", text: "" }], title: " ", width: "250px" }
],
detailInit: detailInitCurrency,
dataBound: function () {
this.expandRow(this.tbody.find("tr.k-master-row").first());
},
}
Allocation Grid Options:
function detailInitCurrency(e) {
if (e.data.allocations)
ctrl.selectedCurrencyAllocations = e.data.allocations;
$("<div/>").appendTo(e.detailCell).kendoGrid({
dataSource: {
transport: {
read: function (e) {
e.success(ctrl.selectedCurrencyAllocations);
},
},
filter: { field: "currencyId", operator: "eq", value: e.data.currencyId },
schema: {
model: {
id: "allocationId",
fields: {
allocationId: { type: "number", editable: false },
allocationName: { type: "string", editable: true },
}
}
}
},
editable: "inline",
toolbar: [{
name: 'create',
text: 'Add Allocation',
}],
columns: [
{
field: "allocationName", title: "Allocation",
editor: function (container, options) {
$('<input kendo-drop-down-list required k-data-text-field="\'currencyName\'" k-data-value-field="\'currencyName\'" k-data-source="ctrl.allocationDataSource" data-bind="value:' + options.field + '"/>')
.appendTo(container);
}
},
{ command: [{ name: "edit", text: "" }, { name: "destroy", text: "" }], title: "", width: "250px" }
]
});
}
Output :
Please feel free to point me out on any code that I may have missed since I have removed a lot of unnecessary code for keeping the problem simple.
Can you tell me page size Change event in Kendo-Angular grid as i am new in kendo grid control. Please help me. Thank you in advance.
app.controller("dataController", function ($compile, dataFactory, $scope, $timeout) {
$scope.obj = [];
$scope.DistrictList = [];
$scope.DistrictTextToShow = "Select District";
$scope.GetDistrict = function () {
dataFactory.getdistrictList().success(function (data) {
$scope.DistrictList = data;
}).error(function (data) {
$.toaster({ priority: 'error', title: 'Error', message: 'Error while fetching data' });
});
};
if ($("#ddldistrict").val() == '') {
$scope.ddldistrict = GuidEmpty;
}
else {
$scope.ddldistrict = $("#ddldistrict").val();
}
$scope.gridData = new kendo.data.DataSource({
serverPaging: true,
serverSorting: true,
transport: {
read: {
url: baselocation + "api/Customer/GetAllCustomerByDistrictId",
data: { DistrictId: $scope.ddldistrict, isactive: $("#ddlstatus").val() }
}
},
schema: {
data: function (data) {
return data.Rows;
},
total: function (data) {
return data.TotalRows;
}
},
pageSize: 5
});
$scope.detailGridOptions = {
sortable: true,
pageable: {
"pageSizes": true,
change: function (e) {
if ($("#ddldistrict").val() == '') {
$scope.ddldistrict = GuidEmpty;
}
else {
$scope.ddldistrict = $("#ddldistrict").val();
}
//$("#grid1").data('kendoGrid').dataSource.pageSize(parseInt(this.value()));
$("#grid1").data('kendoGrid').dataSource.read({ DistrictId: $scope.ddldistrict, isactive: $("#ddlstatus").val() });
$("#grid1").data('kendoGrid').refresh();
}
},
datasource: $scope.gridData,
groupable: true,
scrollable: true,
columns: [{
field: "Customername",
title: "Customer Name",
width: "150px"
}, {
field: "mobile",
title: "Mobile",
width: "120px"
}, {
field: "email",
title: "Email",
width: "120px"
}, {
field: "Districtname",
title: "District",
width: "120px"
}]
};
$scope.GetDistrict();
$scope.BindData = function () {
if ($("#ddldistrict").val() == '') {
$scope.ddldistrict = GuidEmpty;
}
else {
$scope.ddldistrict = $("#ddldistrict").val();
}
$("#grid1").data('kendoGrid').dataSource.read({ DistrictId: $scope.ddldistrict, isactive: $("#ddlstatus").val() });
$("#grid1").data('kendoGrid').refresh();
}
//$("#grid1").kendoPager({
//});
//$scope.gridData.read();
});
Want to call a function when chart is loaded, written that function in listeners, but its getting called before the chart is displayed, any idea which event should I listen to chartRendered or any other
getChartConfig: function(project_oid) {
that = this;
var chart = Ext.getCmp('mychart');
if (chart) {
chart.destroy();
}
return {
xtype:'rallychart',
id: 'mychart',
storeConfig: {
find: {
'_ProjectHierarchy': project_oid,
"$or": [
{"_TypeHierarchy": "HierarchicalRequirement"},
{"_TypeHierarchy": "Defect"}
],
'Children': null
},
fetch: ['PlanEstimate','_TypeHierarchy','ObjectID', 'ScheduleState', '_ValidFrom', '_ValidTo', '_PreviousValues'],
hydrate: ['ScheduleState', '_TypeHierarchy'],
sort: { '_ValidFrom': 1 }
,
/*find: {
'_ProjectHierarchy': project_oid,
"_TypeHierarchy": {
"$in": ['HierarchicalRequirement', 'Defect']
},
'Children': null
},
fetch: ['PlanEstimate','_TypeHierarchy','ObjectID', 'ScheduleState', '_ValidFrom', '_ValidTo', '_PreviousValues'],
hydrate: ['ScheduleState', '_TypeHierarchy'],
sort: { '_ValidFrom': 1 }*/
},
calculatorType: 'CycleCalculator',
chartColors: [ "#6AB17D", "#F47168", "#000000"],
calculatorConfig: {
startDate: Rally.util.DateTime.format(new Date(this._startDate), 'Y-m-d'),
endDate: Rally.util.DateTime.format(new Date(this._endDate), 'Y-m-d'),
startState: this._startState,
endState: this._endState
//granularity: 'week'
},
chartConfig: {
chart: {
type: 'line',
},
title: { text: 'Cycle/Lead Time' },
border: 1,
plotOptions: {
series: {
connectNulls: true,
marker: {
enabled:false
}
}
},
xAxis: {
//tickmarkPlacement: 'on',
tickInterval: 10,
title: {
text: 'Months'
}
},
yAxis: [
{
title: {
text: 'Average Days'
}
}
]
},
listeners: {
snapshotsAggregated: this.showStats,
scope: this
}
}
},
below the is function I want to call
And in showStats() function I want use chart object,,,,please help..thanks in advance
showStats: function(chart) {
console.log("chart values", chart);
var average = Ext.Array.mean(chart.calculator.globalVar);
var average = Ext.Number.toFixed(average, 2);
var min = Ext.Array.min(chart.calculator.globalVar);
var max = Ext.Array.max(chart.calculator.globalVar);
var count = Ext.Array.sum(chart.calculator.globalVar);
console.log("field value", average, min, max, count);
//field.fieldLabel = average;
var stdDev = this.standardDeviation(average, chart.calculator.globalVar);
var stdDev = Ext.Number.toFixed(stdDev, 2);
this.down('#averageId').setText("Average " + average);
this.down('#countId').setText("Count " + count);
this.down('#minId').setText("Minimum " + min);
this.down('#maxId').setText("Maximum " + max);
this.down('#stdDevId').setText("Std Deviation " + stdDev);
},
Your choice of chartRendered is correct- that is the last one to fire.
If it is fires before the chart is fully rendered, it is a bug, but from my tests it looks like it fires at the right time. I do not know what data is stored in your globalVar and how you arrive at it. Perhaps the problem is somewhere else other then the timing of the chartRendered event.
When I modify this example by adding chartRendered event listener, visually the console.log may log a little faster than the chart animation entirely completes, but the chart data is already fully loaded by then, and all the data is complete. I verified that by building a table with a few stats that you use. Here is the full code:
Ext.define('Rally.example.BurnCalculator', {
extend: 'Rally.data.lookback.calculator.TimeSeriesCalculator',
config: {
completedScheduleStateNames: ['Accepted']
},
constructor: function(config) {
this.initConfig(config);
this.callParent(arguments);
},
getDerivedFieldsOnInput: function() {
var completedScheduleStateNames = this.getCompletedScheduleStateNames();
return [
{
"as": "Planned",
"f": function(snapshot) {
if (snapshot.PlanEstimate) {
return snapshot.PlanEstimate;
}
return 0;
}
},
{
"as": "PlannedCompleted",
"f": function(snapshot) {
if (_.contains(completedScheduleStateNames, snapshot.ScheduleState) && snapshot.PlanEstimate) {
return snapshot.PlanEstimate;
}
return 0;
}
}
];
},
getMetrics: function() {
return [
{
"field": "Planned",
"as": "Planned",
"display": "line",
"f": "sum"
},
{
"field": "PlannedCompleted",
"as": "Completed",
"f": "sum",
"display": "column"
}
];
}
});
var PI_OID = 12483739639; //The ObjectID of the PI on which to burn
Ext.define('Rally.example.BurnChart', {
extend: 'Rally.app.App',
requires: [
'Rally.example.BurnCalculator'
],
launch: function() {
this.add({
xtype: 'rallychart',
storeType: 'Rally.data.lookback.SnapshotStore',
storeConfig: this._getStoreConfig(),
calculatorType: 'Rally.example.BurnCalculator',
calculatorConfig: {
completedScheduleStateNames: ['Accepted', 'Released']
},
chartConfig: this._getChartConfig(),
listeners:{
chartRendered: this._getStats,
scope: this
}
});
},
/**
* Generate the store config to retrieve all snapshots for all leaf child stories of the specified PI
*/
_getStoreConfig: function() {
return {
find: {
_ItemHierarchy: PI_OID,
_TypeHierarchy: 'HierarchicalRequirement',
Children: null
},
fetch: ['ScheduleState', 'PlanEstimate'],
hydrate: ['ScheduleState'],
sort: {
_ValidFrom: 1
},
context: this.getContext().getDataContext(),
limit: Infinity
};
},
/**
* Generate a valid Highcharts configuration object to specify the chart
*/
_getChartConfig: function() {
return {
chart: {
defaultSeriesType: 'area',
zoomType: 'xy'
},
title: {
text: 'PI Burnup'
},
xAxis: {
categories: [],
tickmarkPlacement: 'on',
tickInterval: 5,
title: {
text: 'Date',
margin: 10
}
},
yAxis: [
{
title: {
text: 'Points'
}
}
],
tooltip: {
formatter: function() {
return '' + this.x + '<br />' + this.series.name + ': ' + this.y;
}
},
plotOptions: {
series: {
marker: {
enabled: false,
states: {
hover: {
enabled: true
}
}
},
groupPadding: 0.01
},
column: {
stacking: null,
shadow: false
}
}
};
},
_getStats:function(chart){
var stats = [];
console.log(chart);
var series = chart.chartData.series;
_.each(series, function(s){
stats.push({
name : s.name,
average : Ext.Number.toFixed(Ext.Array.mean(s.data), 2),
min : Ext.Array.min(s.data),
max : Ext.Array.max(s.data),
count : Ext.Array.sum(s.data)
});
});
this._showStats(stats);
},
_showStats: function(stats) {
console.log(stats);
this.add({
xtype: 'rallygrid',
store: Ext.create('Rally.data.custom.Store', {
data: stats
}),
columnCfgs: [
{
text: 'Name',
dataIndex: 'name'
},
{
text: 'Average',
dataIndex: 'average'
},
{
text: 'Min',
dataIndex: 'min'
},
{
text: 'Max',
dataIndex: 'max'
},
{
text: 'Count',
dataIndex: 'count'
}
]
});
}
});
I'm trying to make a Kendo Grid that has 2 foreign key columns using the Angular directives for Kendo. I am able to get one to work, but not the other (independent of each other). If I comment one out the other will work and vice versa, but either way only one will work. Abbreviated sample code is below.
invoicesController.js
app.controller('invoicesController', [
'$scope', '$rootScope', 'config', 'dataFactory', function($scope, $rootScope, config, dataFactory) {
$rootScope.title = 'Invoices';
$scope.filterCustomers = [];
$scope.filterStatuses = [];
$scope.invoiceGrid = null;
var _refreshCustomers = function () {
dataFactory.get(_.string.format('{0}customers', config.apiUrl)).success(function (result) {
$scope.filterCustomers = _.map(result, function (cust, key) {
return {
text: cust.name,
value: cust.id
}
});
});
};
var _refreshStatuses = function() {
dataFactory.get(_.string.format('{0}invoicestatuses', config.apiUrl)).success(function(result) {
$scope.filterStatuses = _.map(result.data, function(status, key) {
return {
text: status.name,
value: status.id
}
});
_initializeGrid();
});
};
var _refreshData = function () {
_refreshCustomers();
_refreshStatuses();
};
_refreshData();
var _initializeGrid = function() {
$scope.invoiceGrid = {
dataSource: {
transport: {
read: _.string.format('{0}invoices', config.apiUrl),
},
schema: {
data: 'data'
},
pageSize: 15,
sort: { field: 'invoiceDate', dir: 'asc' }
},
columns: [
{ title: 'Subject', field: 'subject', type: 'string', width: '30%'},
{ title: 'Number', field: 'number', width: '12%' },
{ title: 'Customer', field: 'customer.id', values: $scope.filterCustomers, width: '15%' },
{ title: 'Status', field: 'status.id', values: $scope.filterStatuses, width: '14%' },
{ title: 'Total', field: 'invoiceTotal', type: 'number', format: '{0:c2}', width: '10%' },
{
title: 'Updated', field: 'updatedOn', type: 'date', format: '{0:d}', width: '19%',
template: '#=lastUpdated#'
}
],
scrollable: false,
sortable: true,
filterable: true,
pageable: true
};
}
}
]);
dataFactory.js (GET method)
return $http({
url: url,
method: 'GET',
data: data,
});
list.html
<div data-kendo-grid data-k-ng-delay="invoiceGrid" data-k-options="invoiceGrid" class="top"></div>
I was able to get this to work using route resolve.
Basically, when you're defining your routes, you can set resolvers. In this case, I'm resolving customers and statuses which you will also see as arguments on the projectsController
app.js (routing config)
// Projects
$routeProvider.when('/projects', {
templateUrl: '/app/views/projects/list.html',
controller: 'projectsController',
resolve: {
customers: ['customerService', function (customerService) {
return customerService.getCustomers();
}],
statuses: ['projectService', function (projectService) {
return projectService.getStatuses();
}]
}
});
projectsController.js (abbreviated)
app.controller('projectsController', [
'$scope', '$rootScope', 'config', 'customers', 'statuses', function($scope, $rootScope, config, customers, statuses) {
// Set the options from the injected statuses (from the route resolver)
$scope.statusOptions = _.map(statuses.data.data, function(status) {
return { value: status.id, text: status.name }
});
....
// Kendo grid column definition
columns: [
{ title: 'Status', field: 'status.id', values: $scope.statusOptions, width: '15%' },
]
}]);
i have an EXT.formPanel in which i'd like to have this beahaviour: two buttons should submit through ajax and one shouldn't. How to do this?
This is my code:
form = new Ext.FormPanel({
frame:true,
width:Ext.crl.styles.formWidth,
title: 'Ricerca Atti',
bodyStyle:'padding:5px 5px 0',
defaultType: 'textfield',
formId:'search-form',
keys: [
{ key: [Ext.EventObject.ENTER], handler: function(){
ds.baseParams = form.getForm().getValues();
form.getForm().submit({url:urlRicerca,
waitMsg:'Ricerca in corso…', submitEmptyText: false, method:'GET',params: { start: 0, limit: PAGE_SIZE},
success:function(form,action) {Ext.crl.utils.searchOnSuccess(ds, action, grid); }
});
}
}
],
items: [
ricercaSemplice,
ricercaAvanzata,
{ //This button should submit NOT submit through AJAX!!!
text: 'Esporta Elenco',
disabled:false,
style: 'float:right;',
xtype: 'button',
handler: function() {
ds.baseParams = form.getForm().getValues();
form.getForm().submit({url:urlRicerca+".xls",
waitMsg:'Ricerca in corso…', submitEmptyText: false, method:'GET',params: { enableCsvFilter: "yes", start: 0, limit: PAGE_SIZE},
success:function(form,action) {console.log(action); }
});
}
},{
text: 'Reimposta',
xtype: 'button',
style: 'float:right;margin-right:10px',
disabled: false,
handler: function() {
form.getForm().reset();
//window.location.href = window.location.href;
}
},{
id: 'bottoreCercaRicerca',
name: 'bottoreCercaRicerca',
text: 'Cerca',
xtype: 'button',
style: 'float:right;margin-right:10px',
disabled: false,
handler: function() {
ds.baseParams = form.getForm().getValues();
form.getForm().submit({url:urlRicerca,
waitMsg:'Ricerca in corso…', submitEmptyText: false, method:'GET',params: { start: 0, limit: PAGE_SIZE},
success:function(form,action) {Ext.crl.utils.searchOnSuccess(ds, action, grid); }
});
}
},{
name: 'buttonSwitchRicerca',
xtype: 'button',
style: 'margin-bottom:10px',
text: 'Ricerca Avanzata',
handler: function() {
if(ricercaAvanzata.hidden) {
this.setText('Ricerca Standard');
ricercaAvanzata.show();
}
else {
this.setText('Ricerca Avanzata');
ricercaAvanzata.hide();
}
}
},
DEFAULT_SPACER,
Ext.crl.modalitaLavoro.comboModalitalavoro
]
});
I'v written a comment on where the button should NOT use ajax.
EDIT - i've found a solution, this is an handler that works for not submitting through ajax (actually the fact that opens in a new window is something i want) what i need. Are there any other options?
handler: function() {
query = form.getForm().getValues(true);
query += "&enableCsvFilter=yes";
var url = urlRicerca + ".xls?" + query;
window.open(url);
}
Here is an example :
var ajaxButton1 = new Ext.Button({text:'ajaxButton1 ', handler:ajaxButton1Function});
var ajaxButton2 = new Ext.Button({text:'ajaxButton2 ', handler:ajaxButton2Function});
var noAjaxButton = new Ext.Button({text:'noAjaxButton ', handler:noAjaxButtonFunction});
function ajaxButton1Function(){
Ext.Ajax.Request({
url: 'your url', // you can fix a parameter like this : url?action=anAction1
method: 'POST',
params: {
myField1: myField1.getValue()
// all your params....
},
success: function (result, request){
alert('Succesfully added ' + result.responseText);
},
failure: function (result, request){
alert('Error in server' + result.responseText);
}
});
}
function ajaxButton2Function(){
Ext.Ajax.Request({
url: 'your url', // you can fix a parameter like this : url?action=anAction2
method: 'POST',
params: {
myField1: myField1.getValue()
// all your params....
}
success: function (result, request){
alert('Succesfully added ' + result.responseText);
},
failure: function (result, request){
alert('Error in server' + result.responseText);
}
});
}
function noAjaxButtonFunction(){
form.submit({
success: function(form, action) {
Ext.Msg.alert('Success', action.result.msg);
},
failure: function(form, action) {
Ext.Msg.alert('Failed', action.result.msg);
}
});
}