refresh kitchen sink sencha's left hand side menu - extjs

i want to refresh kitchen sink(http://pydictionary.appspot.com/) sencha's left hand side menu whose data source is json. I have changed the data in .json file but menu doesn't load new data in menu.
data is coming from leftmenu.json
Ext.regModel('Demo', {
fields: [
{name: 'text', type: 'string'},
{name: 'source', type: 'string'},
{name: 'leaf', type: 'boolean'}
]});
sink.StructureStore = new Ext.data.TreeStore({
model: 'Demo',
autoLoad: true,
proxy: {
type: 'ajax',
url: 'leftmenu.json',
reader: {
type: 'tree',
root: 'items'
}
}});
i am trying to reload it in following ways...but not working
sink.StructureStore.setProxy(sink.StructureStore.getProxy());
sink.StructureStore.getRootNode().removeAll();
sink.StructureStore.load();

if your code is correct, after load() list data should automatically change. And we dont need to change the url everytime. only load will work

i just need to add one magical line which i missed
Ext.getCmp("nestedList").onBackTap();
this menu is loaded when user clicks "Table of contents option" of first level menu. now its working

Related

Extjs two instances of stores not using different models

edit http://jsfiddle.net/zns6B/4/ Added js fiddle link and running into a cannot get 'Fields' of undefined now
edit2 So i found that the second grids store model is correct with Sc.Model.B. But the records in the store have ids that are Sc.Model.A . So my store model is set to Sc.Model.B but the store is using Sc.Model.A . It still gets stores the data in the store but only as if the model was set to Sc.Model.A in the first place.
edit3 I have take all the creation of instance out of my ListGrid. I have instead added them when creating the list grid. I have added the following. This does not work either. I am at a lose for what to do.
var obj1 = Ext.create('Sc.ListGrid',{
title: "first Component",
foo: true,
id: 'firstGrid',
myStore: Ext.create('My.Store.MyStore',{model:Ext.create('My.Model.Model'});
renderTo: 'renderToMe1'
});
I am trying to generate these two grids. When foo == true i want it to generate a store with model A. When it equals false i want it to use model B. I have tried to just specifically add the My.Model.MyModel but that does not work. The second grid will somehow inherit the first models model. I have changed it just to try and use fields instead of using the model at all but the second grid still uses the first grids.
I have also tried declaring the Stores inside the initComponent as well but i get the same result either way.
var obj1 = Ext.create('Sc.ListGrid',{
title: "first Component",
foo: true,
id: 'firstGrid',
renderTo: 'renderToMe1'
});
var obj2 = Ext.create('Sc.ListGrid',{
title: "second Component",
foo: false,
renderTo: 'renderToMe2'
});
Sc.ListGrid
Ext.define('Sc.ListGrid', {
extend: 'Ext.grid.Panel',
title: 'Grid',
store: Ext.data.StoreManager.lookup('bleh'),
requires: ['stuff'],
columns: [
{ text: 'id', dataIndex: 'id' },
],
config:{
foo: null,
},
initComponent: function(){
if(this.foo == true){
Ext.apply(this,{
store: this.buildStore1()
});
}
if(this.foo == false){
Ext.apply(this,{
store: this.buildStore2()
});
}
this.callParent();
},
buildStore1:function(){
return Ext.create('Sc.Store.League.LeagueStore',{url:'somewhere',fields:["S"]});
},
buildStore2:function(){
return Ext.create('Sc.Store.League.LeagueStore',{url:'somewhere',fields:["A"]});
}
});
Also an example of a model i am trying to use as well.
Ext.define('Sc.Model.A', {
extend: 'Ext.data.Model',
fields: [
{name: 'id', type: 'string'},
{name: 'type', type: 'string'},
{name: 'gamename', type: 'string'}
]
});
Ext.define('Sc.Model.B', {
extend: 'Ext.data.Model',
fields: [
{name: 'id', type: 'string'},
{name: 'type', type: 'string'},
{name: 'gamename', type: 'string'},
{name: 'something1', type: 'string'},
{name: 'something2', type: 'string'},
]
});
It will create both grids and load the data from my webservice. When i check the grid with Sc.Model.B's data it will have id and type. But will not have any data for something1, and something2. My webserivce is returning json and all values are entered. There are no nulls. If i Ext.getCmp('firstGrid').getStore().getData(0); If i use Ext.getCmp('firstGrid').getStore() and check the model name. It shows Model B but reflects A
Do you need it to be done in the initComponent()??
This is a fiddle I saved from a while ago when I was trying to do something similar. If you need help tweaking it let me know and ill update it.
The main thing to note is the grid.reconfigure(store,columns);
That will change the grid's store and columns appropriately.
http://jsfiddle.net/zqG55/1/
The issue was that the proxy wasn't being set or created properly because the proxy model was referencing the previous model instance. This is my solution
var themodel = 'A.Model.SomeModel';
var myProxy = new Ext.data.proxy.Ajax({
model: themodel,
url: url,
reader: {
type: 'json',
}
});
Ext.apply(this,{
columns: modelColumns.columns,
store: Ext.create('M.Store.MyStore',{
model: themodel ,
autoLoad: true,
proxy: myProxy
})
});

ExtJS GridPanel "show in groups" not displayed/ not working

I encountered some weird behavior on GridPanel feature of ExtJs. I have included a groupField config option and it is not displayed and as well not working. Maybe you guys can give me an idea why?
createStore : function(itemPath) {
return new
CQ.Ext.data.GroupingStore({
proxy : new CQ.Ext.data.HttpProxy(
{
url : "/bin/test/private/folder/check.json",
method : "GET"
}),
//method: "GET",
reader: new CQ.Ext.data.JsonReader({
root: 'variables',
fields: [
{name: 'group', type: 'string'},
{name: 'path', type: 'string'},
{name: 'status', type: 'string'}
]
}),
updateData : function() {
// request the data
this.load({
params : {
path : itemPath
}
});
},
sortInfo: {field: 'path', direction:'ASC'},
groupField: 'group',
groupOnSort: true,
autoLoad : true
});
},
If you want your groups to be displayed in the grid panel, you also need to add the grouping feature to your grid.
Where is updateData coming from? I am not seeing it in the documentation anywhere. Is that piece of code causing the issue?
Here is the example from Sencha: http://dev.sencha.com/deploy/ext-3.4.0/examples/grid/grouping.html
Make sure you are viewing the 3.4 documentation too.

JsonStore loads records and marks them phantom

My JsonStore is so defined:
var data_json = new Ext.data.JsonStore({
url: '/Game/json_index',
autoLoad: true,
id: 'data_json',
idProperty: 'id',
fields: [ {name: 'id', type: 'int'}, 'name', {name:'add_date', type:'date', dateFormat: 'M$'}, 'price', 'kind', 'metacritic'],
listeners: { 'load': function(storename, records, options){
console.dir(this);
}},
writer: new Ext.data.JsonWriter()
})
the DUMP of the JSON it's receiving it's something like:
[
{"id":1,"name":"Guild Wars 2","add_date":"\/Date(1346104800000)\/","price":24.99,"kind":"MMO","metacritic":93},
{"id":2,"name":"Dark Souls: Prepare to Die Edition","add_date":"\/Date(1345759200000)\/","price":45.00,"kind":"actionrpg","metacritic":87},
{"id":3,"name":"Orcs Must Die! 2","add_date":"\/Date(1343599200000)\/","price":15.00,"kind":"action","metacritic":83}
]
the JSON is correctly decoded and the store is full of my records, but beware.. terrible things have happened!
All of the records have been marked as phantom = true, that doesn't let me correctly use ExtJS 3.4.x store.save() functionality
I've searched thoroughly on google about this issue, and (i think) it's connected to the fact the JsonReader doesn't associate the record id to the 'id' field i'm passing.
I have even specified idProperty: 'id'.
Help on this? I'm getting desperate, reading the extjs source about record creation is pure pain.
Try removing the:
id: 'data_json'
from your store. All the config options to a JsonStore are passed into the JsonReader that's automatically created, and that seems to be what's screwing it up.

ExtJS4: Value read in Store does not get populated in datafield

As part of my EXTJS 4 learning process, I am trying to establish a simple process of database connection - loading a value in a data Store - taking the value and placing it in a dataField.
The data is loaded fine from the php script and placed into the Store via a json call. (as confirmed through FireBug)
However, the dataField, does not seem to be able to load the value.
Here is what I have so far:
//Model definition
Ext.define('FingerModel', {
extend: 'Ext.data.Model',
fields: [
{name: 'name', type: 'string'}
]
});
//Store Definition
var est_data = new Ext.data.Store({
model: 'FingerModel',
proxy: {
type: 'ajax',
url: 'finger.php',
extraParams: {opt: 'getName'},
reader: {
type: 'json',
root: 'results',
totalProperty: 'total'
}
},
autoLoad: true,
// turn off remote sorting
remoteSort: false
});
//Form definition
var fingerForm = Ext.create('Ext.form.Panel', {
width: 500,
title: 'Finger',
waitMsgTarget: true,
items: [{
xtype: 'fieldset',
title: 'Finger Form',
items: [{
xtype:'textfield',
fieldLabel: 'Location Name',
name: 'name'
}]
}]
});
fingerForm.getForm().loadRecord(FingerModel);
Anybody see anything obvious that I'm doing wrong?
Thanks in advance.
M.
Ext.form.field.Text does not have a 'store' property. How would it know which row of the store to use?
You should use Form.loadRecord() to load the model into the form, and it will set form fields with the same name as the model field names.

Adding table inside a dynamically added tab

I'm fairly new to ExtJS. I adopted some examples and added the functionality to add tabs to a tab-control by clicking on some link. so far so good. Now I want to load a ExtJS table into on of the new tabs. the items (rows, columns) are defined in a database on the server side. Can you give me some hints how to add the table automatically when the tab is created?
Autoload is good for pulling an HTML table from your server-side code. Does this data ever get updated? If so you will need to reload the entire HTML. I would suggest using a grid instead:
// tabPanel definitinon
{
xtype:"grid",
//tabId is a unique value created at the time of the tab
id:"general_props_status_grid_" + tabId,
ds: C.createStore({
storeId:"general_props_status_grid_" + tabId,
autoLoad:true
proxy: new Ext.data.HttpProxy({
//path to a serverside page that gerenates a JSON table contents
url: '?fuseaction=qry_statuses'
}),
reader: new Ext.data.JsonReader({
id: 'status_id',
root:'data'
}, [
{name: 'status_id'},
{name: 'name'}
]),
remoteSort: false
}),
columns:[{
header: "Status ID",
dataIndex: 'status_id',
width:20,
hidden:true,
sortable:true
},{
header: "Name",
dataIndex: 'name',
hideable:false,
renderer:function(val){
return "<span class='link'>" + val +"</span>"
},
width:150,
sortable:true
}],
sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
loadMask: true,
listeners: {
activate:function(thisGrid){
//this will reload the grid each time this tab is selected
thisGrid.getStore().reload();
}
}
}
There are a ton of options for grids, but the above example shows an automatically updating grid via callbacks.
ok, i did some further reading i thing tha autoLoad property is helping me a lot here.
i will go from here.

Resources