PDA

View Full Version : hide some group in grid



Mycoding
3 Jul 2010, 4:53 AM
Please, give me advice.
There are several references, depending on which we click
in grid should to show only one group.
As far as I understood that should be done with help of changing store.
But how?

Condor
3 Jul 2010, 5:31 AM
You could filter the store so it only contains the records for the selected group or you could hide all other groups in the dom.

Mycoding
3 Jul 2010, 5:34 AM
Could you help me how to filter?
You mean something like this store.filter('Group'); ?
I don't know how to make it.

By click on reference this function runs



function showZadachniki(subject){
var allSubjects=[['matan','?????????????? ??????'],['difur','???????????????? ?????????'],['tfkp','?????? ??????? ??????????? ??????????'],['terver','?????? ??????????? ? ???????????? ??????????'],['phisics','?????? ????????????'],['algebra','???????'],['geometry','?????????'],['phisicsSchool','?????? ????????']],
indexSubject;
for(var i=0;i<allSubjects.length;i++){
if(allSubjects[i][0]==subject){indexSubject=i;}
}

var store = new Ext.data.GroupingStore({
groupField: 'subject',
data: [
[1,'?????????','2006','4462','demidovich_small.jpg','?????????????? ??????'],
[2,'????????',' 2000','','fillippov-small.jpg','???????????????? ?????????'],
[3,'?????? ????? ??<br> ?????? ???????<br> ???????????<br> ??????????',' ','','volkovinskii.jpg','?????? ??????? ??????????? ??????????']
],
reader: new Ext.data.ArrayReader({id:'id'}, ['id','title','year','numZadach','image','subject'])
});
function title_book_renderer(val, x, store){return '<b>'+store.data.title+'</b>';}
function year_book_renderer(val, x, store){return '<b>'+store.data.year+'</b>';}
function numZadach_book_renderer(val, x, store){return '<b>'+store.data.numZadach+'</b>';}
function image_book_renderer(val, x, store){return "<img src='/subjects/images_of_book/"+store.data.image+"'/>";}

var gridZadachniki = new Ext.grid.GridPanel({
frame:true,
height:300,
width:385,
store: store,
autoExpandColumn: 'title',
columns: [
{header: "????????", dataIndex: 'title', renderer: title_book_renderer, id: 'title'},
{header: "??? ???????", dataIndex: 'year', renderer: year_book_renderer, id: 'year'},
{header: "?????????? ?????", dataIndex: 'title', renderer: numZadach_book_renderer, id: 'numZadach'},
{header: "???????", sortable: true, dataIndex: 'subject',hidden:true},
{header: "??? ????????", dataIndex: 'image', renderer: image_book_renderer, id: 'image'}
],
view: new Ext.grid.GroupingView({
forceFit:true,
groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "???????" : "??????????"]})'
})
});

if(!winZadachniki){
winZadachniki = new Ext.Window({
id:'winZadachniki',
layout:'fit',
closeAction:'hide',
resizable:true,
iconCls: 'smallImageBook',
width:550,
height:400,
frame:true,
closable:true,
collapsible: true,
animateTarget:subject,
items: gridZadachniki
});
}
else{winZadachniki.hide();}
winZadachniki.setTitle('???????? ???????? ?? ??????????: '+allSubjects[indexSubject][1]);
winZadachniki.setAnimateTarget(subject);
winZadachniki.show();
//store.groupBy('subject');

//store.filter('TYPE','File',false,false);
}

Animal
3 Jul 2010, 5:55 AM
Actually, because of generated element IDs, you could add overrides to hide groups.

Eg "ext-gen13-gp-industry-Computer" is the id for the "Computer Industry" group in the demo.

Mycoding
3 Jul 2010, 6:43 AM
I tried to do like this

store.filter('subject',allSubjects[indexSubject][1],false,false);
But when I click on another reference that run the some function, override filter did't work,
and shows the group I chekc in first time.

Condor
3 Jul 2010, 7:04 AM
So you need to filter one or more groups? And how do you select groups (what does allSubjects contain)?

Mycoding
3 Jul 2010, 7:17 AM
I have at the moment three groups of student subject in every one there is one book.
When we click on reference we needs to show only one group of three.
It means to filter by groups, check the needed group.
You can look it at the site http://http://vreshenie.ru/

Mycoding
3 Jul 2010, 9:06 AM
I mean I cann't refresh grid
I'm trying
gridZadachniki.getView().refresh();
But that doesn't work

Animal
3 Jul 2010, 9:19 AM
Honestly.

Try just hiding the group using its generated ID!

Mycoding
3 Jul 2010, 9:25 AM
But how?
Groups didn't have id.
Or maybe I did groping wrong?

I found something I need, but I don't understand how that hide group
http://www.sencha.com/deploy/dev/examples/tasks/tasks.html
Here hides some groups.

Animal
3 Jul 2010, 9:46 AM
Just LOOK at the DOM!