I am attempting to create a rallymultiobjectpicker that lists the users of a workspace. However, it does not seem to load any values for the displayField, regardless of what it is set to in the listCfg. The documentation specifies that the default is "Name," to which I have switched around to "FirstName," "ObjectID", "DisplayName," "_refObjectName," etc. No changes seem to be reflected, as the divs that should contain the values for the displayField remain empty. I have checked the objects, and here is an example of what is typically returned (all empty fields are generated and not modified):
->Object
CreationDate: null
Disabled: false
DisplayName: ""
EmailAddress: ""
FirstName: ""
LastName: ""
LastPasswordUpdateDate: null
MiddleName: ""
ObjectID: 1234567890
OnpremLdapUsername: ""
RevisionHistory: ""
Role: ""
ShortDisplayName: ""
Subscription: ""
TeamMemberships: ""
UserName: ""
UserPermissions: ""
UserProfile: ""
_objectVersion: "12"
_p: "2"
_ref: "https://rally1.rallydev.com/slm/webservice/1.33/user/1234567890.js"
_refObjectName: "John D"
_type: "user"
creatable: false
deletable: false
groupSelected: "Available"
matchedText: undefined
updatable: true
__proto__: Object
Here is an example of the code used:
Ext.widget('rallymultiobjectpicker', {
modelType: 'user',
fieldLabel: 'Owners',
listCfg: {displayField: "DisplayName", autoScroll: true},
stateful: false,
labelWidth: 50,
});
EDIT: Using a similar configuration as the one listed in the answer below, this issue has arisen again in 2.0p3. There is no option text shown, despite having the displayField specified in the listCfg. I should also note that the filters/customQuery seem to be completely broken, as they don't function to limit the data set I have in another rallymultiobjectpicker.
You must specify a data store configuration that fetches the displayField from the server. You'll have to specify the entire store configuration, not only the fetch parameter. You'll also have to pass a config option for the filterFieldName for the auto complete functionality to work properly. An example configuration is below:
Ext.widget('rallymultiobjectpicker', {
modelType: 'user',
fieldLabel: 'Owners',
filterFieldName: 'DisplayName',
storeCfg: {
autoLoad: false,
fetch: 'DisplayName',
pageSize: 200,
sorters: [
{
property: 'DisplayName',
direction: 'ASC'
}
],
remoteGroup: false,
remoteSort: false,
remoteFilter: false,
limit: Infinity
},
listCfg: {
displayField: 'DisplayName'
},
stateful: false,
labelWidth: 50
});
Related
I'm using the sequelize module for my node.js mvc project and the query i'd like to execute is the following
SELECT answer_text, isNew, name FROM answer JOIN topic ON answer.topic_id = topic.id
answer_text and isNew are columns of the answer table while name is a column that only exists in the topic table.
How can i have the topic table name column appear in the results next to isNew column so that i can access it easily? Does sequelize provide such a feature or it's my responsibility to format the result?
I've tried to add various things in attributes like 'topic.name' but none worked.
The way i've set up the file structure is based on their documentation Sequelize usage with express
var models = require('../models')
var answers = await models.Answer.findAll({
include: [{
model: models.Topic
}],
attributes: [
'answer_text',
'isNew'
]
})
console.log(answers)
The output of the following is
{ answer_text: 'maybe it is robots',
isNew: true,
Topic:
Topic {
dataValues:
{ id: 830,
mid: 'm.0bjmp5',
name: 'Robot Arena',
description:
'Robot Arena is a computer game made by Infogrames. It features robotic combat similar to that of Battlebots Robotica and Robot Wars. There are a number of different chassis and on top of that there are numerous attachments. Weapons accessories tires and other forms of mobility batteries and air tanks are among the customization choices. A sequel called Robot Arena 2 Design and Destroy was made which allows for total customization of your
robot.',
type: 'cvg.computer_videogame' },
_previousDataValues:
{ id: 830,
mid: 'm.0bjmp5',
name: 'Robot Arena',
description:
'Robot Arena is a computer game made by Infogrames. It features robotic combat similar to that of Battlebots Robotica and Robot Wars. There are a number of different chassis and on top of that there are numerous attachments. Weapons accessories tires and other forms of mobility batteries and air tanks are among the customization choices. A sequel called Robot Arena 2 Design and Destroy was made which allows for total customization of your
robot.',
type: 'cvg.computer_videogame' },
_changed: {},
_modelOptions:
{ timestamps: false,
validate: {},
freezeTableName: false,
underscored: false,
paranoid: false,
rejectOnEmpty: false,
whereCollection: null,
schema: null,
schemaDelimiter: '',
defaultScope: {},
scopes: {},
indexes: [],
name: [Object],
omitNull: false,
sequelize: [Sequelize],
hooks: {} },
_options:
{ isNewRecord: false,
_schema: null,
_schemaDelimiter: '',
include: undefined,
includeNames: undefined,
includeMap: undefined,
includeValidated: true,
raw: true,
attributes: undefined },
isNewRecord: false } }
Please try the following sequelize statement -
var answers = await models.Answer.findAll({
include: [{
model: models.Topic,
attributes: ['name']
}],
attributes: [
'answer_text',
'isNew'
],
raw: true
})
I hope it helps!
Working answer:
Sequelize must be required in order to use [sequelize.col('Topic.name'), 'name'] inside attributes so that we can fetch name column of Topic table and rename 'Topics.name' to name. (Tried models.col but it is not a function)
raw: true is required if you want to get only the columns inside answers[0]
attributes:[] is required inside include because if you don't put it the result will include all the columns from the joined table (Topic).
const models = require('../models')
const sequelize = require('sequelize');
var answers = await models.Answer.findAll({
include: [{
model: models.Topic,
attributes: []
}],
attributes: [
'answer_text',
'isNew',
[sequelize.col('Topic.name'), 'name']
],
raw: true
})
console.log(answers[0])
output:
{ answer_text: 'robot arena',
isNew: 'true',
name: 'Robot Arena' }
I am trying to create a kendo grid with excel export. My data is shown precisely as I want it and the grid works fine. However, the saveAsExcel function triggers the excelExport event, but no file is created. Same problem with the pdf export.
Here is my grid options:
grid = $("#grid").kendoGrid({
toolbar:["excel","pdf"],
height: 500,
scrollable: true,
groupable: true,
sortable: true,
filterable: false,
excel: {
allPages:true,
filterable:true
},
excelExport: function(e) {
console.log('Firing Export');
console.log(e.workbook);
console.log(e.data);
},
pdfExport: function(e){
console.log('PDF export');
},
columns: [
{ field: "date", title: "Time", template: "#= kendo.toString(kendo.parseDate(date), 'MM/dd/yyyy') #", width: '120px'},
{ field: "customer", title: "Customer" },
{ field: "amount", title: "Total", format: "{0:c}", width: '70px', aggregates: ["sum"]},
{ field: "paid_with", title: "Payment", width: '130px'},
{ field: "source", title: "Source" },
{ field: "sale_location", title: "Sale Location" }
]
}).data("kendoGrid");
This ajax is called whenever the search parameters for the data is changed. Where I refresh the datasource.
$.ajax({
'url':'/POS/ajax/loadTransactionsDetailsForDay.php',
'data':{
filters
},
'type':'GET',
'dataType':'json',
'success':function(response) {
var dataSource = new kendo.data.DataSource({
data: response.data.invoices,
pageSize: 100000,
schema: {
model: {
fields: {
date: {type: "string"},
customer: { type: "string" },
amount: { type: "number" },
paid_with: {type: "string"},
source: {type:"string"},
sale_location: {type:"string" }
}
}
}
});
grid.setDataSource(dataSource);
grid.refresh();
}
});
The output from my console log is.
Firing Export.
A worksheet object.
Object {sheets: Array[1]}sheets: Array[1]0: Objectlength: 1__proto__: Array[0]__proto__: Object
and and array with these objects for every row in the grid:
0: o
_events: Object
_handlers: Object
amount: 40.45
customer: "customer 1"
date: "2015-11-25T00:00:00-08:00"
dirty: false
employee: 23
paid_with: "Check"
parent: ()
sale_location: "Main"
source: "POS"
uid: "70b2ba9c-15f7-4ac3-bea5-f1f2e3c800d3"
I have the latest version of kendo, I am loading jszip. I am running it on the latest version of chrome.
I have tried all kinds of variations of this code I can think of, including removing my schema, initializing the kendo anew every time in the callback.
Anyone got any idea why this would not work?
Every example on this I can find make it look super simple, just create the grid and call export... So I have to have overlooked something.
I am grateful for any ideas about this.
Thanks.
It could be because the filename is missing.
Here the part with the filename added:
excel: {
allPages:true,
filterable:true,
fileName: "Kendo UI Grid Export.xlsx"
},
You can take a look here : Grid Excel Export
And here for the pdf: Grid Pdf Export
I have some following suggestion.
Can you add kendo deflate pako script file into your code and try.
Then remove the pdf export event and just try to export a pdf with toolbar default functionality..check whether its working or not.
try to add a data-source ajax call with in a grid option using kendo-transport technique with read method. http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-transport
This is my model:
data: i
0: i
data: Object
events: Object
hasListeners: k
id: "region-ext-record-344"
index: 0
internalId: "ext-record-344"
modified: Object
phantom: false
raw: Array[2] // i want to get those two elements one displayField, another valueField
0: "01"
1: "Region 1"
length: 2
__proto__: Array[0]
store: i
stores: Array[1]
__proto__: Object
1: i
2: i
3: i
length: 4
__proto__: Array[0]
I can post the code if you want to!
I tried to read store like:
store: regionStore, but it is showing me an empty box with 4 empty lines equal to item count in my store, then I tried to do like store: regionStore.data.items and now it shows me [object object] lines, I totally get it why, but can't find solution for that. I am new to all ExtJs stuff, I am using ExtJs 4 though.
My model looks like that :
Ext.regModel('region', {
fields: [
{name: 'id', type: 'integer'},
{name: 'name', type: 'String'}
});
and my store looks like that:
var regionStore = new Ext.data.ArrayStore({
id: 'regionStore',
model: 'region',
data: MyDesktop.GridWindow.getRegionData() //that is data from ajax response
});
My combobox:
{
xtype: 'combobox',
value: "region",
store: regionStore,
width: 135,
id: 'regionCombo'
editable: false
}
You have tagged your question extjs 4.2, but your code is old style and not following recommendations. I really recommend you to read the manual, especially the introduction to MVC.
Ext.regModel is deprecated as of version 4.0.0. Change your code as follows and save it to the file app/model/Region.js :
Ext.define('MyApp.model.Region', {
extends: 'Ext.data.Model',
fields: [
{name: 'id', type: 'integer'},
{name: 'name', type: 'string'}
]
});
In file app/store/Regions.js :
Ext.define('MyApp.store.Regions', {
extends: 'Ext.data.ArrayStore',
//id: notice that id is no longer necessary
model: 'Region',
//data: you load the store from the server, so the data is loaded automatically
autoLoad: true
})
Your combobox becomes:
xtype: 'combobox',
value: 'region',
store: 'Regions',
width: 135,
id: 'regionCombo',
editable: false,
valueField: 'id',
displayField: 'name'
I never used extjs before 4.2, but it seems the changes introduced with version 4 are important. It may be difficult to adopt the new paradigms. But I'm sure it radically simplifies your code. You certainly never will regret this step.
Also with the release of version 5.0, I think it's time to develop new habits and leave ExtJs 2.0 coding style behind.
You started off correctly, but you didn't specify which fields to use. Add the missing configuration :
store: regionStore,
valueField: 'id',
displayField: 'name'
For a combobox you can define a store inline as :
store: [[1, 'first option'], [2, 'second option']],
In this case you will not need to declare the value and the display field. They are implicit.
I have been trying to render JSON data in a JQGrid. I get the following error:
Error: b is undefined
Source File: http://localhost:1302/Scripts/jquery.jqGrid.min.js
Line: 23
When I use the un-minimized JQGrid source code I see that it makes multiple calls to the getAccessor method and on the last call the first parameter to the method (obj) is passed an undefined value:
Error: obj is undefined
Source File: http://localhost:1302/Scripts/jquery.jqGrid.src.js
Line: 151
That seems to be what's causing the grid to stop rendering, but why?
The rendered grid shows the column headings but the no contents. The "Loading..." message in the grid never disappears.
My JSON data look like this:
{
"total":"1",
"page":"1",
"userdata":{
},
"records":"2",
"rows":[
{
"DateOfBirth":"11/04/2012 12:00:00 AM",
"DisambiguationNote":"Boring guy",
"FirstName":"Joe",
"LastName":"Bloggs",
"MiddleName":"Binkie",
"PersonId":"1"
},
{
"DateOfBirth":"01/01/2001 12:00:00 AM",
"DisambiguationNote":"someone else",
"FirstName":"Edna",
"LastName":"Edwards",
"MiddleName":"Edith",
"PersonId":"8"
}
]
}
My grid code looks like this:
$(function () {
$("#persongrid").jqGrid({
url: '/Person/List',
datatype: 'json',
mtype: 'GET',
jsonreader: {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false,
id: "5" ,
cell: "" ,
userdata: "userdata"
},
colModel: [
{ name: 'DateOfBirth', index: 'DateOfBirth',sorttype:'date' },
{ name: 'DisambiguationNote', index: 'DisambiguationNote' },
{ name: 'FirstName', index: 'FirstName' },
{ name: 'LastName', index: 'LastName' },
{ name: 'MiddleName', index: 'MiddleName' },
{ name: 'PersonId', index: 'PersonId',sorttype:'int' }
],
pager: '#persongridpager',
rowNum: 10,
rowList: [10, 20, 30],
viewrecords: true,
gridview: true,
caption: 'People'
});
});
I can see that the JSON data is being retrieved as above from the AJAX request, and I have been through the JSON data instructions for JQGrid quite carefully but can't see what I'm doing wrong.
Can anyone help? Thank you.
The error is very easy, but it's difficult to find: you use jsonreader instead of jsonReader and so the jsonreader will be ignored and the default jsonReader will be used.
How you can see on the demo the data will be successfully read after the modification.
By the way, you can specify only the properties of jsonReader which are different from defaults and use
jsonReader: {
repeatitems: false,
id: "5",
}
or
jsonReader: {
repeatitems: false,
id: "PersonId",
}
I added to the demo height: 'auto' option only to improve the visibility.
I have a ExtJS (4.0) grid and it works fine. Now I want it to advance it a bit by adding filters to it. I want users to be able to filter items by the status.
I have created the following store:
var status_store = Ext.create('Ext.data.Store', {
model: 'Statuses',
proxy: {
type: 'ajax',
url: '/json/statuses/',
reader: 'json'
}
});
and I can see it loads, /json/statuses/ will return the following json object:
[
{
"name": "OK",
"isActive": true
},
{
"name": "Outdated",
"isActive": true
},
{
"name": "New",
"isActive": true
}
]
Now I define the filters:
var filters = {
ftype: 'filters',
encode: encode,
local: local,
filters: [{
type: 'list',
dataIndex: 'name',
store: 'status_store',
labelField: 'name'
}]
};
and add the filter to my column definition:
{text: 'Status', width: 120, dataIndex: 'status', sortable: true, filterable: true, filter: {type: 'list'}},
What happens is I get the following error when the grid loads:
Uncaught TypeError: Object json has no method 'read' (ext-all-debug.js:25702)
and when I click on the column header for the menu:
Uncaught TypeError: Object status_store has no method 'on' (ListMenu.js:69)
How can I fix this or am I doing something conceptually wrong?
Here is the full quote of my code just in case: http://pastebin.com/SNn6gFJz
Thanks for Diagnosing the problem. The 4.1 fix is this modify ListMenu.js
in the else part of the constructor
replace
me.store.on('load', me.onLoad, me);
with
// add a listener to the store object
var storeObject = Ext.StoreMgr.lookup(me.store);
storeObject.on('load', me.onLoad, me);
me.store = storeObject;
filters: [{
type: 'list',
dataIndex: 'name',
store: 'status_store',
labelField: 'name' ,
options:[a,b]
}]
You also have to give the options in list filters.
I was having a similar problem. I followed the #jd comment on the other answer here but the options menu just said "loading...". I resolved it with a bit of a hack here.