We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Use PivotGrid with view of sql entity

Thread ID:

Created:

Updated:

Platform:

Replies:

143466 Mar 20,2019 08:12 PM UTC Mar 25,2019 08:45 AM UTC ASP.NET Web Forms 6
loading
Tags: PivotGrid
Guadalupe
Asked On March 20, 2019 08:12 PM UTC

Hello
I need to example for add dates to PivotGrid with to view of sql Entity Framework or with to DataTable. 
When is the correct option? I can use PivotGrid1.(What) for this?

Arulraj A [Syncfusion]
Replied On March 21, 2019 12:16 PM UTC

Hi Guadalupe, 

Thanks for contacting Syncfusion support. 

You can render PivotGrid with DataTable as datasource. Please follow the below steps. 

Step 1: 
 
Add the following class into the WebAPI controller file. 

Code Snippet:[c#] 
public class DbaseQuery 
{ 
public dynamic GetSQLResult(dynamic clientParam) 
{ 
string conSTR = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=" + AppDomain.CurrentDomain.BaseDirectory + @"App_Data\Database1.mdf;Integrated Security=True";//SQL database connection string 
string xquery = "SELECT * FROM table1"; 
SqlConnection sqlConn = new SqlConnection(conSTR); 
sqlConn.Open(); 
SqlCommand cmd = new SqlCommand(xquery, sqlConn); 
SqlDataAdapter da = new SqlDataAdapter(cmd); 
DataTable dt = new DataTable(); 
da.Fill(dt); 
 
 
for (var i = 0; i < dt.Rows.Count; i++) 
{ 
for (var j = 0; j < dt.Rows[i].ItemArray.Length; j++) 
{ 
  dt.Rows[i].ItemArray[j] = dt.Rows[i].ItemArray[j].ToString().Trim(); 
} 
}//datasource 
 
return dt; 
}} 
 
Step 2:  
Call the GetSQLResult method in each method of PivotGrid WebAPI controller to feed datasource to the control.(Like, InitializeGrid, fetchMembers..etc.) 
 
Code Snippet:[C#] 
public Dictionary<string, object> InitializeGrid(Dictionary<string, object> jsonResult) 
{ 
htmlHelper.PivotReport = BindDefaultData(); 
dict = htmlHelper.GetJsonData(jsonResult["action"].ToString(), dbquery.GetSQLResult(null));  
return dict; 
} 


 

Please let us know if you need any further assistance. 

Arulraj A 


Guadalupe
Replied On March 21, 2019 02:33 PM UTC

Hello
I cant view the example with VisualStudio.


Guadalupe
Replied On March 21, 2019 08:59 PM UTC

Hello
I need use pivotgrid with to view of SQL Entity Framework.
This is possible?

Arulraj A [Syncfusion]
Replied On March 22, 2019 06:53 AM UTC

Hi Guadalupe, 

Thanks for the update. 

We have provided the sample as per your requirement. The sample project can be opened using Visual Studio 2017, the project file name is “PivotDataTable.csproj”. Please check the sample and let us know if you need further assistance on this. 

Arulraj A 


Guadalupe
Replied On March 22, 2019 12:55 PM UTC

Good morning!

I have VisualStudio 2015. Please you can reply the proyect in my version?

Thank you!

Arulraj A [Syncfusion]
Replied On March 25, 2019 08:45 AM UTC

Hi Guadalupe, 

Thanks for the update. 

As per your requirement we have prepared sample in 4.5 framework which will work in Visual Studio 2015. 

Please let us know if you have any concerns. 
 
Arulraj A 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;