How to bind datatable

Dear sir/mam,


Please help me how to bind datatable to pivot client.


2 Replies 1 reply marked as answer

SS Saranya Sivan Syncfusion Team February 3, 2021 06:11 PM UTC

Hi Shivanand  
    
We are validating the reported requirement. And we will update you the further details in two business days.   
      
Regards,    
Saranya Sivan.   
 



SS Saranya Sivan Syncfusion Team February 5, 2021 05:32 PM UTC

Hi Shivanand   
  
Based on your requirement we have prepared a sample to bind the data table in the pivot client. Please check the below sample for your reference. 
  
  
Kindly define the data table in the App_Code---> RelationalClientController.cs as mentioned in the below code snippet. 
  
Code Example: 
  
  public Dictionary<string, object> InitializeClient(Dictionary<string, object> jsonResult) 
        { 
            this.BindData(); 
             return pivotClient.GetJsonData(jsonResult["action"].ToString(), GetDataTables(), jsonResult["clientParams"].ToString()); 
        } 
  
    public DataTable GetDataTables() 
        {      
            DataTable dt = new DataTable("Student"); 
            dt.Columns.Add("StudentId", typeof(Int32)); 
            dt.Columns.Add("StudentName", typeof(string)); 
            dt.Columns.Add("Address", typeof(string)); 
            dt.Columns.Add("MobileNo", typeof(string)); 
            dt.Rows.Add(1, "Manish", "Hyderabad", "0000000000"); 
            dt.Rows.Add(2, "Venkat", "Hyderabad", "111111111"); 
            dt.Rows.Add(3, "Namit", "Pune", "1222222222"); 
            dt.Rows.Add(4, "Abhinav", "Bhagalpur", "3333333333"); 
            return dt; 
        } 
  
  private void BindData() 
        { 
this.pivotClient.PivotReport.PivotRows.Add(new PivotItem { FieldMappingName = "StudentName", FieldHeader = "Student Name", TotalHeader = "Total", ShowSubTotal = false }); 
            this.pivotClient.PivotReport.PivotRows.Add(new PivotItem { FieldMappingName = "StudentId", FieldHeader = "Student Id", TotalHeader = "Total" }); 
            this.pivotClient.PivotReport.PivotColumns.Add(new PivotItem { FieldMappingName = "Address", FieldHeader = "Address", TotalHeader = "Total", ShowSubTotal = false }); 
this.pivotClient.PivotReport.PivotCalculations.Add(new PivotComputationInfo { CalculationName = "MobileNo", Description = "MobileNo", FieldHeader = "MobileNo", FieldName = "MobileNo",     Format = "N", SummaryType = Syncfusion.PivotAnalysis.Base.SummaryType.DoubleTotalSum }); 
        } 
  
  
  
  
We hope the above sample meets your requirements. Please let us know if you have concern. 
  
Regards, 
Saranya Sivan. 



Marked as answer
Loader.
Up arrow icon