This is a migrated thread and some comments may be shown as answers.

Updating RadGrid Groups Client Side

1 Answer 183 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alexandre Fromage
Top achievements
Rank 1
Alexandre Fromage asked on 04 Sep 2009, 02:18 PM
Hi there,

I have a question about radGrid clien-side databinding, using WebServices.
In my RadGrid, I'm grouping datas function of a column. When I update dynamically(client-side) my datagrid, grouping doesn't seem to work well:
independently of the number of elements which belong to the group, this one have always have the same number of items.
Here, I'm grouping fonction of MembreConvers wich is a string.
        <MasterTableView ClientDataKeyNames="IdContact" GroupLoadMode="Client"   
                        NoMasterRecordsText="" ShowHeadersWhenNoRecords="true" Width="100%">  
                        <GroupByExpressions> 
                            <telerik:GridGroupByExpression> 
                                <SelectFields> 
                                    <telerik:GridGroupByField FieldAlias="MembreConvers" FieldName="MembreConvers"   
                                        HeaderText="Participe" /> 
                                </SelectFields> 
                                <GroupByFields> 
                                    <telerik:GridGroupByField FieldName="MembreConvers" /> 
                                </GroupByFields> 
                            </telerik:GridGroupByExpression> 
                        </GroupByExpressions> 
            <Columns> 
                <telerik:GridMaskedColumn DataField="MembreConvers"   
                                SortExpression="MembreConvers">  
                            </telerik:GridMaskedColumn> 
<!-- Continue --> 

And I'm updating it with that javascript, client-side. I need to pass args to my WebMethod, so I'm not using Telerik's codeLess method.
//Called When WebService GetContactListForConversation return              
function SucceededCallbackGetParticipants(result, eventArgs) {  
 
                //Conversation ID - and so window - is in eventArgs.  
                //It allows us to get current conversation's radWindow  
                  
                var radWindowManager = GetRadWindowManager();  
                var window_ = radWindowManager.getWindowById(eventArgs);  
 
                if (window_ != null) {  
                      
                      //Get the frame  
 
                    var frame = window_.get_contentFrame();  
 
                      //Get the window  
                    var windowContent_ = frame.contentWindow;  
 
                    var radGrid = windowContent_.$find("RadGridContacts");  
 
                    //Get Master TableView  
                    var tableView = radGrid.get_masterTableView();  
 
                       //Set dataSource and DataBind  
                    tableView.set_dataSource(result);  
                    tableView.dataBind();  
 
                    //Using setTimeout instead of setInterval(firefox compatible)  
                    setTimeout(function() { GetParticipantsForConversation(eventArgs) }, timeout);  
                } 

WebService returns List<Contact>:
    public class Contact  
    {  
        public string NomPrenom { getset; }  
        public int IdContact { getset; }  
        public string EnLigne { getset; }  
 
        public string MembreConvers { getset; }  
     // Continue here ....  
On page load, server-side, in "RadGridContacts_NeedDataSource" method I create MasterTableView like that:
//Test                    
  List<Contact> contactsList = new List<Contact>();  
               //there will be 2 groups : "Oui" and "Non".  
              contactsList.Add(new Contact("", 0, true"Oui"));  
              contactsList.Add(new Contact("", 0, true"Non"));   RadGridContacts.MasterTableView.DataSource = contactsList;  
 
/*And when I'm updating Client-side, group "Oui" and "Non" are limited to 1 item each. How can I fill them client-side?*/ 
Is there an easy trick to update these groups client-side?

Thanks a lot,

Alex.

1 Answer, 1 is accepted

Sort by
0
Alexandre Fromage
Top achievements
Rank 1
answered on 07 Sep 2009, 08:25 AM
I found that on the forum:
http://www.telerik.com/community/forums/reply-thread.aspx?messageId=0&threadId=190189
Hello kiwo,

RadGrid does not support grouping on the client, therefore there is no way that you can remove grouping only with javascript. You can call the table view's ungroupColumn('ColumnUniqueName') method from your javascript handler but it will make a postback on the server. So in any case a round-trip to the server is necessary for the ungrouping to be achieved.

Regards,
Tsvetoslav
the Telerik team

I've managed to do it another way.
Thx.
Tags
Grid
Asked by
Alexandre Fromage
Top achievements
Rank 1
Answers by
Alexandre Fromage
Top achievements
Rank 1
Share this question
or