This is a migrated thread and some comments may be shown as answers.
MasterTable Rebind on client side does not work for Detail table?
1 Answer 74 Views
This is a migrated thread and some comments may be shown as answers.
mfmz
Top achievements
Rank 1
mfmz asked on 26 May 2009, 10:40 AM
I have a grid with master and detail table view. If I rebind master table on client side by setting args.set_cancel(true); in OnCommand client side event it only bind with master table and but dont bind with detail table although I explicitly rebind each detail table after rebind master table but it does not work. If I rebind only each detail table it bind successfully.

addCompany2() called on button click.
var companies = null;
    var empId = -1000;
    var curDataItem = null;
    var companyId = -100;
    
    $(document).ready(pageLoad);
    
    function pageLoad()
    {
        companies = [{"CompanyID":1,"CompanyName":"Moftak","Employees":[{"CompanyId":1,"FirstName":"Naeem","EmployeeID":1,"LastName":"Dad","Title":"","TitleId":0,"BirthDate":"","ShiftStart":"","JoinDate":""},{"CompanyId":1,"FirstName":"Nabil","EmployeeID":2,"LastName":"Manzoor","Title":"","TitleId":0,"BirthDate":"","ShiftStart":"","JoinDate":""}]},{"CompanyID":2,"CompanyName":"Chillisauce","Employees":[{"CompanyId":2,"FirstName":"James","EmployeeID":1,"LastName":"T","Title":"","TitleId":0,"BirthDate":"","ShiftStart":"","JoinDate":""},{"CompanyId":2,"FirstName":"Will","EmployeeID":2,"LastName":"Z","Title":"","TitleId":0,"BirthDate":"","ShiftStart":"","JoinDate":""}]},{"CompanyID":3,"CompanyName":"Microsoft","Employees":[{"CompanyId":3,"FirstName":"Niclus","EmployeeID":1,"LastName":"Gage","Title":"","TitleId":0,"BirthDate":"","ShiftStart":"","JoinDate":""},{"CompanyId":3,"FirstName":"Peter","EmployeeID":2,"LastName":"Khan","Title":"","TitleId":0,"BirthDate":"","ShiftStart":"","JoinDate":""}]}];        
        if(companies == null)
            companies = new Array();
    } 
var bindIndex = 0;


function addCompany2()
    {                 
        debugger;   
        var company = new Object();
        company.CompanyName = "Test Company";
        company.CompanyID = companies.length+1;
        
        companies[companies.length] = company;           
        
        var grd = $find("<%= RadGrid1.ClientID %>");                       
                   
        document.getElementById("hdCompanies").value = $.toJSON(companies);  
           
        grd.get_masterTableView().rebind();     
        
        for(var i=0;i<companies.length;i++)
        {
            if(grd.get_detailTables()[i] != null)
            {
                grd.get_detailTables()[i].rebind();
                bindIndex++;
            }
            
        }    
        bindIndex = 0;
    }          
    
    function OnCommand(sender,args)
    {
       args.set_cancel(true);
       
       if(args.get_commandName() == "RebindGrid")
       {   
          resetContainers();
                                       
          if(args.get_tableView().get_name() == "Company")
          {            
            sender.get_masterTableView().set_dataSource(companies);
            sender.get_masterTableView().dataBind();                    
          }
          
          if(args.get_tableView().get_name() == "Employee")
          {            
            sender.get_detailTables()[bindIndex].set_dataSource(companies[bindIndex].Employees);
            sender.get_detailTables()[bindIndex].dataBind();                    
          }
       }                    
    }


1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 29 May 2009, 04:14 PM
Hello,

Please refer to the following post:
Bind Detail Table on Client Side

Kind regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
mfmz
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or