Kendo Grid DateColumn show NaN/NaN/NaN - angularjs

In every grid (Kendo for AngujarJs) on my project that contains a DateTime value I'm getting this NaN/NaN/NaN
Here is my schema:
schema: {
model: {
id: 'RequestId',
fields: {
RequestId: { type: 'number' },
RequestNumber: { type: 'number'},
FileNumber: { type: 'string' },
RegistrationDate: { type: 'datetime' },
RequestStatus: { type: 'string' },
UnitName: { type: 'string' }
}
}
}
I've tried with RegistrationDate: { type: 'string' }, or RegistrationDate: { type: 'date' }, but nothing change, also I tried this on my columns:
{
field: 'RegistrationDate',
title: 'Fecha de Registro',
type: 'date'
},
Or type: 'datetime' and nothing.
Here is what I get from the server:
Any idea on how to make it work? Its pretty basic to show a Date in a grid, I know, in other projects I have no problem, but as you can see, I tried all I could think of.

Try this:
{
field: 'RegistrationDate',
title: 'Fecha de Registro',
format: "{0:yyyy-MM-dd HH:mm:ss}"
}

Related

unexpected token ",", expected expression in sanity studio vision

I am following a course on react native and We are using Sanity as our backend. I have already set the schemas and made the adjustments in my Sanity Studio.
HERE IS MY FEATURED SCHEMA CODE:
export default {
name: 'featured',
title: 'featured Menu Categories',
type: 'document',
fields: [
{
name: 'name',
type: 'string',
title: 'Featured category name',
validation: (Role) => Role.required(),
},
{
name: 'short_description',
type: 'string',
title: 'Short description',
validation: (Role) => Role.max(200),
},
{
name: 'restuarants',
type: 'array',
title: 'Restuarants',
of: [{ type: 'reference', to: [{ type: 'restuarant' }] }],
},
],
};
HERE IS MY RESTAURANT SCHEMA CODE:
export default {
name: 'restaurant',
title: 'Restuarant',
type: 'document',
fields: [
{
name: 'name',
type: 'string',
title: 'Restuarant name',
validation: (Role) => Role.required(),
},
{
name: 'short_description',
type: 'string',
title: 'Short description',
validation: (Role) => Role.max(200),
},
{
name: 'image',
type: 'image',
title: 'Image of the Restuarant',
},
{
name: 'lat',
type: 'number',
title: 'latitude of the restaurant',
},
{
name: 'long',
type: 'number',
title: 'longitude of the restaurant,
},
{
name: 'address',
type: 'string',
title: 'Address of the Restuarant',
validation: (Role) => Role.required(),
},
{
name: 'rating',
type: 'number',
title: 'Enter a rating of (1 - 5)',
validation: (Role) =>
Role.required()
.min(1)
.max(5)
.error('please enter a number between 1 - 5'),
},
{
name: 'type',
type: 'string',
title: 'Category',
validation: (Role) => Role.required(),
type: 'reference',
to: [{ type: 'category' }],
},
{
name: 'dishes',
type: 'array',
title: 'Dishes',
of: [{ type: 'reference', to: [{ type: 'dish' }] }],
},
],
};
I also did one for the dish and category.
Then I went to my Sanity Studio to fill in my restaurant schema fields;
After I went to my Vision Board in Sanity Studio and did a query(Just like the instructor):
*[_type == "featured"]{
...,
restuarants[]=> {
...,
dishes[]=> ,
type=> {
name
}
},
}
And I got an error of:
unexpected token ",", expected expression ;
I did what any developer would have done if they got an error. I double-checked my code and compared it to the instructor in the video. (I still got the error). Then I googled it(And found no answer). It's been 2 days now and I still haven't found anything.
This is my first querying in Sanity and I am not sure what I am doing wrong with my query. Can anyone please help me? Thanks.
As the error mentioned, you missed a ' in your schema code.
Keep a ' after restaurant
{
name: 'long',
type: 'number',
title: 'longitude of the restaurant',
},
No worries I found the answer to my problem. The problem was with my querying.
HERE WAS MY CODE BEFORE:
*[_type == "featured"]{
...,
restuarants[]=> {
...,
dishes[]=> ,
type=> {
name
}
},
}
THIS IS HOW I WAS SUPPOSED TO WRITE IT:
*[_type == "featured"]{
...,
restuarants[]-> {
...,
dishes[] -> ,
type-> {
name
}
},
}
I was supposed to use a straight line instead of an equal sign.
I hope this helps anyone who runs into this problem

watermelonDb: how pass array of string as a column type in schema?

i want to set type of serverNames as a array of string but in watermelon it supports only boolean, string and number ,anybody help me over this
export const settingSchema = tableSchema({
name: 'SETTINGS',
columns: [
{ name: 'serverId', type: 'number' },
{ name: 'server', type: 'string' },
{ name: 'base_url', type: 'string' },
{ name: 'serverNames', type: 'string', },//<-----serverNames,type:'[string]
{ name: 'amberIcon', type: 'boolean' },
{ name: 'showAllResident', type: 'boolean' },
{ name: 'showAllTask', type: 'boolean' },
{ name: 'filterStart', type: 'number' },
{ name: 'filterEnd', type: 'number' },
{ name: 'searchedText', type: 'string' },
{ name: 'currentTab', type: 'number' },
{ name: 'appInit', type: 'boolean' },
{ name: 'performRefresh', type: 'boolean' },
{ name: 'slowMessageDisplay', type: 'boolean' },
{ name: 'backgroundListener', type: 'boolean' },
{ name: 'displayResidentHeader', type: 'boolean' },
{ name: 'currentResident', type: 'string', isOptional: true },
]
})
You can use a json field type for that I believe. https://nozbe.github.io/WatermelonDB/Advanced/AdvancedFields.html#json

Mongo DB - Lookup and Count is taking longer to execute

I am facing slow query execution time issues with MongoDB.
My Basic scenario is, I am developing a Classifieds website on Sails ( Node ) using MongoDB (Linux-x86_64-3.4.4) as Database.
I have two collections
ad - To save advertisement details ( 194419 records / 753.84 mb )
ad_attrs - To save advertisement attributes details ( 689883 records / 148.75 mb )
We have 2 Different category for users - Personal and Professional. So, we save it to ad collection, Each record contains its type as Personal or Professional.
Now, I want to display total counts of ad based on user's search filters like below
So, I have used below queries to make it possible. but, It been a problem with its performance now.
When I try to Query using Lookup with attrs it's taking 7.5 - 12 Seconds and When I only Query Ad table it's taking 0.2-1.2 seconds.
db.ad.aggregate(
[
{
"$match":{
"$and":[
{
"is_active":{
"$eq":1
}
},
{
"is_delete":{
"$eq":0
}
},
{
"is_block":{
"$eq":0
}
},
{
"is_online":{
"$eq":1
}
},
{
"ad_type":{
"$eq":"offers"
}
}
]
}
},
{
"$lookup":{
"from":"ad_attr",
"localField":"_id",
"foreignField":"ad_id",
"as":"attrs"
}
},
{
"$addFields":{
"totalAttrs":{
"$size":"$attrs"
}
}
},
{
"$project":{
"ad_user_type":1,
"attrs":1
}
},
{
"$group":{
"_id":null,
"cnt":{
"$sum":1
},
"pro":{
"$sum":{
"$cond":[
{
"$eq":[
"$ad_user_type",
"professional"
]
},
1,
0
]
}
},
"per":{
"$sum":{
"$cond":[
{
" $eq":[
"$ad_user_type",
"personal"
]
},
1,
0
]
}
}
}
}
]
)
Collection Structure is as below
Ad Collection
{
attributes: {
_id: {
type: 'string'
},
user_id: {
type: 'string'
},
title: {
type: 'string'
},
description: {
type: 'longtext'
},
price: {
type: 'float'
},
price_max: {
type: 'float'
},
ad_type: {
type: 'string'
},
ad_user_type: {
type: 'string'
},
zipcode: {
type: 'string'
},
lat: {
type: 'float'
},
long: {
type: 'float'
},
loc: {
type: 'object'
},
cityzip: {
type: 'string'
},
town: {
type: 'string'
},
town_slug: {
type: 'string'
},
region: {
type: 'string'
},
region_slug: {
type: 'string'
},
department: {
type: 'string'
},
department_slug: {
type: 'string'
},
address: {
type: 'longtext'
},
telephone: {
type: 'string'
},
is_account_address: {
type: 'integer',
defaultsTo: 1
},
is_phone_hide: {
type: 'integer',
defaultsTo: 0
},
video: {
type: 'string'
},
is_video_check: {
type: 'integer',
defaultsTo: 0
},
is_urgent: {
type: 'integer',
defaultsTo: 0
},
additional_picture: {
type: 'integer',
defaultsTo: 0
},
is_in_showcase: {
type: 'integer',
defaultsTo: 0
},
showcase_date: {
type: 'date'
},
showcase_duration: {
type: 'string',
defaultsTo: ""
},
showcase_duration_id: {
type: 'string'
},
is_in_top_list: {
type: 'integer',
defaultsTo: 0
},
top_list_date: {
type: 'date',
defaultsTo: ''
},
top_list_duration: {
type: 'string',
defaultsTo: ""
},
top_list_duration_id: {
type: 'string'
},
is_direct_sale: {
type: 'integer',
defaultsTo: 0
},
is_active: {
type: 'integer',
defaultsTo: 0
},
is_block: {
type: 'integer',
defaultsTo: 0
},
post_on_from_backend: {
type: 'date',
defaultsTo: ''
},
post_on: {
type: 'date',
defaultsTo: ''
},
post_end_on: {
type: 'date',
defaultsTo: ''
},
payment_status: {
type: 'string',
defaultsTo: 'pending'
},
price_token: {
type: 'string',
},
total_views: {
type: 'integer',
defaultsTo: 0
},
total_clicks: {
type: 'integer',
defaultsTo: 0
},
is_online: {
type: 'integer',
defaultsTo: 0
},
is_change_req: {
type: 'integer',
defaultsTo: 0
},
have_shop: {
type: 'integer',
defaultsTo: 0
},
shop_id: {
type: 'string',
defaultsTo: 0
},
slug: {
type: 'string'
},
category: {
type: 'string'
},
category_price: {
type: 'integer',
defaultsTo: 0
},
parent_category: {
type: 'string'
},
user_ip: {
type: 'string'
},
is_delete: {
type: 'integer',
defaultsTo: 0
},
product_name: {
type: 'string'
},
product_price: {
type: 'float',
defaultsTo: 0
},
original_item_quantity: {
type: 'float',
defaultsTo: 0
},
item_quantity: {
type: 'float',
defaultsTo: 0
},
shipping_type: {
type: 'string'
},
shipping_value_simple: {
type: 'float',
defaultsTo: 0
},
shipping_value_variable_min_1: {
type: 'integer',
defaultsTo: 0
},
shipping_value_variable_max_1: {
type: 'integer',
defaultsTo: 0
},
shipping_value_variable_1: {
type: 'float',
defaultsTo: 0
},
shipping_value_variable_min_2: {
type: 'integer',
defaultsTo: 0
},
shipping_value_variable_max_2: {
type: 'integer',
defaultsTo: 0
},
shipping_value_variable_2: {
type: 'float',
defaultsTo: 0
},
shipping_value_variable_min_3: {
type: 'integer',
defaultsTo: 0
},
shipping_value_variable_max_3: {
type: 'integer',
defaultsTo: 0
},
shipping_value_variable_3: {
type: 'float',
defaultsTo: 0
},
seller_paypal_url: {
type: 'string',
defaultsTo: ""
},
direct_sale_opt_1: {
type: 'string',
defaultsTo: ""
},
direct_sale_value_1: {
type: 'longtext',
defaultsTo: ""
},
direct_sale_opt_2: {
type: 'string',
defaultsTo: ""
},
direct_sale_value_2: {
type: 'longtext',
defaultsTo: ""
},
direct_sale_opt_3: {
type: 'string',
defaultsTo: ""
},
have_update: {
type: 'integer',
defaultsTo: 0
},
update_payment_status: {
type: 'string',
defaultsTo: ""
},
direct_sale_value_3: {
type: 'longtext',
defaultsTo: ""
},
attrs: {
collection: 'ad_attr',
via: 'ad_id'
},
reference: {
type: 'longtext',
defaultsTo: ""
},
emp_id: {
type: 'string',
defaultsTo: "0"
},
},
}
Ad Attribtues Collection
attributes: {
ad_id:{
model:'ad'
},
cat_id:{
type:'string',
},
attr_id:{
type:'string',
},
value:{
type:'string',
},
integer_value:{
type:'float',
defaultsTo: 0,
}
}
Index Added for Collections
Ad - I have added indexes to all attributes those are used for Condition
Id , loc , post_on, price, ad_type, is_delete, is_active, is_online, is_block, ad_user_type, attrs, category, parent_category, region_slug, department_slug, town_slug, slug
Ad Attributes
Id, attr_id, value, ad_id, attrs
Server Configurations - It's fine for the current database size
100 GB SSD
8 GB RAM
4 Core Processor
I have done so far
- Google for all possibilities
- Removing attributes those are not needs to query for count and list
I want you to help me with below questions
Shall I improve my Collection structure to make it faster?
Shall I move some attributes to another collection, which are not used to Query for count?
Shall I need to upgrade Mongo config settings or what?
Shall I need to upgrade my server hardware?
Experts, I need your help to resolve this. Thanks in advance! :)

Create a view to display nested data

My Model
config:{
fields: [
{ name: 'AcctManagFirst', type: 'string' },
{ name: 'AcctManagLast', type: 'string' },
{ name: 'Name', type: 'string' },
{ name: 'Terms', type: 'string' },
{ name: 'Freight', type: 'string' },
{ name: 'Taxable', type: 'string' },
{ name: 'Taxtable', type: 'string' },
{ name: 'TaxTableRate', type: 'string' },
{ name: 'BillToAddr', type: 'string' },
{ name: 'BCity', type: 'string' },
{ name: 'BState', type: 'string'},
{ name: 'BZip', type: 'string' },
{ name: 'WHAddr', type: 'string' },
{ name: 'WHCity', type: 'string' },
{ name: 'WHState', type: 'string' },
{ name: 'WHZip', type: 'string' },
and my store
config:{
model: 'Sample.model.User',
proxy:
{
type: 'jsonp',
url: 'http://xxx.xxx.com/customer_info.php',
buildUrl : function (request) {
var url = this.getUrl(request),
params = request.getParams() || {};
url = url + params.CustNo;
request.setUrl(url);
return this.callParent([request]);
},
reader: {
type: 'json',
rootProperty: 'content'
}
}
I will get the user data from the store... how to write a view that display data with respect to the user.. user data changes .. now I can write the static data but I need the data to be dynamic..
Firstly, your question is awfully vague and difficult to answer.
I think what you're trying to accomplish is to have a list populated dynamically from your store which when tapped will display a detail view.
You'll need to put together a list view to display your data as well as a container for the detail view.
You will also need a controller with a reference to both views and a control on the list view's itemtap event. The method called from that control should set the data into your detail view then push that view onto the Viewport.
I can be more specific but as I mentioned this question is too vague to put together any kind of example for you. Adding a hardcoded set of data to your store would help, as well as full class examples of your views, stores, controllers and models.

same store with diffrent data types in extjs

I have store which is used for grid and column chart but the values are in form of string (server side formatted amounts which cant be done at client side).due to which grid is not being rendered due to amount in string format.the solution might be make separate store with required data types for grid and chart.but this is inefficient way because same data is coming from server.
here is what i am doing
if (!window.GridModel) {
if (!Ext.ModelManager.isRegistered('GridModel')) {
Ext.define('GridModel', {
extend: 'Ext.data.Model',
fields: [{
name: 'LocCode',
type: 'string'
}, {
name: 'LocLvl',
type: 'string'
}, {
name: 'LocName',
type: 'string'
},
{
name: 'cost1',
type: 'string'
}, {
name: 'Cost2',
type: 'string'
}, {
name: 'cost3',
type: 'string'
}
]
});
}
}
for chart (not deficient)
if (!window.chartModel) {
if (!Ext.ModelManager.isRegistered('chartModel')) {
Ext.define('chartModel', {
extend: 'Ext.data.Model',
fields: [{
name: 'LocCode',
type: 'string'
}, {
name: 'LocLvl',
type: 'string'
}, {
name: 'LocName',
type: 'string'
},
{
name: 'cost1',
type: 'float'
}, {
name: 'Cost2',
type: 'float'
}, {
name: 'cost3',
type: 'float'
}
]
});
}
}
one way might be copy one store into another with changed data type of fields but i don't know how to copy one store into another with changed data type of fields.
I am using ExtJS 4.0.7
You can have different types in the same store, but you have to load them manually, or use some trickery when loading.
Not sure if you can have totally different types, but you can use different subtypes.
Here is an example of changing store type on the fly based on the response:
http://extjs-tutorials.blogspot.ca/2012/06/polymorphic-json-change-model-subclass.html

Resources