I want to get some additional data in the dataSource to use it in the dataBound event.
Here is transport I use in the grid:
"transport" : {
"read" : {
"url" : "f?p=120:0:701647109622339:PLUGIN=BC",
"dataType" : "json",
},
},
"pageSize" : 20,
"schema" : {
data : "row",
total : "total",
rowsdata : "rowsdata",
model : {
"id" : "doc_id",
}
},
I want to access rowsdata via $('#grid').data("kendoGrid").dataSource.data().rowsdata. Is it possible?
Here is a jsfiddle: http://jsfiddle.net/M8jvz/10/
In this particular case, I want to pass a list of permanently hidden columns into HideGrouped function
Here is the fiddle with the solution http://jsfiddle.net/Casufi/4ya83/2/
$('#grid').data("kendoGrid").dataSource.data()
Returns array. And what is that rowsdata inside your schema? Such configuration is not supported.
How to send addtional arguments to the server is covered here.
You can use dataSource.schema.data as an function to achieve what you want:
var dataSource = new kendo.data.DataSource({
"autoSync" : true,
"data" : l_json,
"pageSize" : 20,
"schema" : {
data : function(data){
data.rowsdata[0] = { hidden: 0, name: "name" }
return data.row;
},
...
Documentation here:
http://docs.kendoui.com/api/framework/datasource#configuration-schema.data
Related
I am implementing search result view to my app.
I figured out that mongoose internally provide full text search function with $text.
I put the code below to Post.js
PostSchema.index({desc: 'text'}); //for example
Here's the code I put in my routing file route/posts.js
Post.find({$text: {$search : 'please work!'}}).exec(function (err, posts) {...})
The error message I come up with is below
Index with pattern: { _fts: "text", _ftsx: 1 } already exists with different options
Would there any body who know how to deal with this error and figure out?
Thanks you.
check on which field you have your text index defined. Right now mongodb allows only one text index per collection. so if you have defined a text index on desc column and try to use that index on some other column you are bound to get this error.
can you try to query your index and see on which column you created it. To get indexes you can do
db.collection.getIndexes()
and it will return something like this
[
{
"v" : 1,
"key" : {
"_id" : 1
},
"name" : "_id_",
"ns" : "some.ns"
},
{
"v" : 1,
"key" : {
"_fts" : "text",
"_ftsx" : 1
},
"name" : "desc_text",
"ns" : "some.ns",
"weights" : {
"title" : 1
},
"default_language" : "english",
"language_override" : "language",
"textIndexVersion" : 2
}
]
now if you want to scope in other columns also to use this index simply drop this index
db.collection.dropIndex('desc_text');
and then recreate it by including all columns you want to be covered by text index,
db.collection.createIndex({
title:'text;,
body: 'text;,
desc: 'text',
...... and so on
});
i am new to dojo,..struggling alot in this please help.....
i am using the filter plugin in EnhancedGrid in dojo....i am doing great at client side but coming to server side i dont know how to call the servlet and get the filtered rows in to grid please help in this .....
i tried something like this....
grid = new EnhancedGrid({
id : 'grid',
store : yourStore,
structure : layout,
rowSelector : '20px',
plugins : {
search : true,
pagination : {
pageSizes : [ "50", "100"],
description : true,
sizeSwitch : true,
pageStepper : true,
gotoButton : true,
maxPageStep : 2,
position : "bottom"
},
filter : {
closeFilterbarButton : true,
ruleCount : 5,
ruleCountToConfirmClearFilter:2,
itemsName : "rows",
isServerSide:true,
isSateful:true,
url:"http:myaddress:8080/GridExample/Filter",
setupFilterQuery: setupFilter
}
}
});
var setupFilter = function(commands, request){
if(commands.filter && commands.enable){
// some filter is defined and valid. You can modify the request object here.
}else{
// no filter is valid.
}
};
grid.placeAt("myGrid");
grid.startup();
}
});
First : have you load the Plugin correct?
dojo.require("dojox.grid.enhanced.plugins.Filter");
And maybe this helps you with your Problem:
http://dojotoolkit.org/reference-guide/1.8/dojox/grid/EnhancedGrid/plugins/Filter.html#introduction-to-server-side-filtering
Regards
UPDATE 1
Hi there!
I have to dig a little into the width of the Web but lately i think i found the answer to your question how to define the filter.
plugins: {
filter: {
isServerSide: true,
setupFilterQuery: function(commands, request){
if(commands.filter && commands.enable){
console.log(commands.filter);
request.query = {
"Name": "L*"
}
}
}
itemsName:'songs',
closeFilterbarButton: true,
ruleCount: 8
}
}
I grab this from here: https://bitbucket.org/dojo/dojox/src/64328839903b/grid/tests/enhanced/test_enhanced_grid_filter.html
This example defines a filter that searches the store for all Names that begins with the letter "L". With the other supported Operators you can define your own filter.
http://dojotoolkit.org/reference-guide/1.9/dojox/grid/EnhancedGrid/plugins/Filter.html#supported-operators
Hope this helps you!
Regards
How to add metadata for jstree on select_node event. This is how I am trying to add:
$.ajax({
type : 'GET',
url : '/assessment/getassess',
dataType : 'json',
success : function(jsonData) {
$("#treeViewDiv").jstree({
"themes" : {
"theme" : "classic",
"dots" : true,
"icons" : true,
"url" : "/css/themes/classic/style.css"
},
"json_data" : jsonData,
"plugins" : ["themes", "json_data", "ui", "contextmenu"],
"contextmenu" : {
items : createMenu
}
}).bind("select_node.jstree", function(e, data) {
$(data.rslt.obj).data("jstree").description = "Size: 45units";
});
}
});
I believe you are using the $.data() function incorrectly.
You don't assign values to the results of the $.data() function, and have it be automagically saved.
What you want to do is change this line,
$(data.rslt.obj).data("jstree").description = "Size: 45units";
to this,
// On the next line, we use "|| {}" because if the data attribute is unassigned, we want to start with a default empty object.
var jstreeData = $(data.rslt.obj).data("jstree") || {};
// assign the property(ies)/value(s) you want.
jstreeData.description = "Size: 45units";
// finally, reassign your modified object back to the data attribute.
$(data.rslt.obj).data("jstree", jstreeData);
If the data attribute consist of an object, you want to:
Cache the object;
Modify the cached object;
Save/assign the modified cached object back to the data attribute.
Lastly, to modify a data attribute, you want to use the $.data( key, value ) function overload.
I've got backbone-relational working fairly well so far. I have relationships and reverse relationships well established (see below). When I initially call .fetch() on my Country model instance, the nominees array is parsed out into nominee models perfectly.
When I call .fetch() again later, however, these related models do not update, even though the nominee data has changed (e.g. the vote count has incremented). Essentially it seems that Backbone's .set() method understands relationships initially but not subsequently.
Country Model
var Country = Backbone.RelationalModel.extend({
baseUrl : config.service.url + '/country',
url : function () {
return this.baseUrl;
},
relations : [
{
type : Backbone.HasMany,
key : 'nominees',
relatedModel : Nominee,
collectionType : Nominee_Collection,
reverseRelation : {
key : 'country',
includeInJSON : false
}
}
]
});
JSON Response on country.fetch()
{
"entrant_count" : 1234,
"vote_count" : 1234,
"nominees" : [
{
"id" : 3,
"name" : "John Doe",
"vote_count" : 1,
"user_can_vote" : true
},
{
"id" : 4,
"name" : "Marty McFly",
"vote_count" : 2,
"user_can_vote" : true
}
]
}
Any help would be greatly appreciated, as always.
So it appears that backbone-relational specifically forgoes updating relations automatically (see the updateRelations method), and simply emits a relational:change:nominees event which your models can target. If, however, you wish to programmatically update your related models, simply modify the updateRelations method as follows:
Backbone.RelationalModel.prototype.updateRelations = function( options ) {
if ( this._isInitialized && !this.isLocked() ) {
_.each( this._relations || [], function( rel ) {
// Update from data in `rel.keySource` if set, or `rel.key` otherwise
var val = this.attributes[ rel.keySource ] || this.attributes[ rel.key ];
if ( rel.related !== val ) {
this.trigger( 'relational:change:' + rel.key, this, val, options || {} );
// automatically update related models
_.each(val, function (data) {
var model = rel.related.get(data.id);
if (model) {
model.set(data);
} else {
rel.related.add(data);
}
});
}
}, this );
}
};
(Note that this does not handle deletion of models from a collection, only updates to existing models, and the addition of new models to a collection)
I have a json store that returns values in json format. Now I need to get the number of rows/records in the json string but when I use store.getCount() function it returns 0, but the combobox is populated with rows, and when I use store.length I get undefined, probably because its not an array anymore, its returning from store, which is calling php script. Anyways, whats the best approach for this problem?
Try this out:
var myStore = Ext.extend(Ext.data.JsonStore, {
... config...,
count : 0,
listeners : {
load : function(){
this.count = this.getCount();
}
}
Ext.reg('myStore', myStore);
and then use inside panels:
items : [{
xtype : 'myStore',
id : 'myStoreId'
}]
Whenever you need to get the count then you can simply do this:
Ext.getCmp('myStoreId').count
Your Json response from server, can be something like this...
{
"total": 9999,
"success": true,
"users": [
{
"id": 1,
"name": "Foo",
"email": "foo#bar.com"
}
]
}
Then you can use reader: {
type : 'json',
root : 'users',
totalProperty : 'total',
successProperty: 'success'
} in your store object.
As from docs if your data source provided you can call getTotalCount to get dataset size.
If you use ajax proxy for the store, smth like
proxy : {
type : 'ajax',
url : 'YOUR URL',
reader : {
type : 'json',
root : 'NAME OF YOUR ROOT ELEMENT',
totalProperty : 'NAME OF YOUR TOTAL PROPERTY' // requiered for paging
}
}
and then load your store like
store.load();
There will be sent Ajax asynchronous request, so you should check count in callback like this
store.load({
callback : function(records, operation, success) {
console.log(this.getCount()); // count considering paging
console.log(this.getTotalCount()); // total size
// or even
console.log(records.length); // number of returned records = getCount()
}
});