Group the grid from a data table or sqldatareader


Good morning, I was trying to load the data on the grid using aspx and cs in C #. First the data in a SQLDataReader but it showed me the correct number of rows with no value. Then hp changed using a DATATABLE and it worked. I have enabled the AllowGrouping = "true" property later, and the drag and drop does not work. I forced the column to display the c # using the following code this.gr_TotaliAgenti.GroupSettings.GroupedColumns.Add ("Field"); but I get the following writing in each line ContentPlaceHolder1_gridtest_JSONTemplateContentPlaceHolder1_gr_Tot


The code in cs is as follows in page_load :
SqlConnection _SqlConnection = new SqlConnection(Public_Variable.Current.Public_sConnectionString); _SqlConnection.Close(); string sSelect = "select * from ##tmp";// "select Anno from visp_dettaglio group by anno order by Anno desc "; SqlCommand objsQLCommand = new SqlCommand(sSelect, _SqlConnection); objsQLCommand.CommandTimeout = 0; _SqlConnection.Open(); SqlDataReader dr = objsQLCommand.ExecuteReader(CommandBehavior.CloseConnection); DataTable dtSchema = dr.GetSchemaTable(); DataTable dt = new DataTable(); List<DataColumn> listCols = new List<DataColumn>(); if (dtSchema != null) { foreach (DataRow drow in dtSchema.Rows) { string columnName = System.Convert.ToString(drow["ColumnName"]); DataColumn column = new DataColumn(columnName, (Type)(drow["DataType"])); column.Unique = (bool)drow["IsUnique"]; column.AllowDBNull = (bool)drow["AllowDBNull"]; column.AutoIncrement = (bool)drow["IsAutoIncrement"]; listCols.Add(column); dt.Columns.Add(column); } } while (dr.Read()) { DataRow dataRow = dt.NewRow(); for (int i = 0; i < listCols.Count; i++) { dataRow[((DataColumn)listCols[i])] = dr[i]; } dt.Rows.Add(dataRow); } this.gr_Test.DataSource = dt; _SqlConnection.Close(); this.gr_TotaliAgenti.GroupSettings.GroupedColumns.Add("AgenteCDesc");

In aspx :

   <div class="col-md-4" >
                <ej:Grid ID="gr_Test" runat="server" AllowPaging="true"  AllowFiltering="true" AllowGrouping="true"> 


                </ej:Grid>
    </div>



Gazie for the help. Greetings


4 Replies

CS Carmelo Scarpello May 17, 2018 01:28 PM UTC


Always starting from the previous result by activating the responsive property IsResponsive = "true" the total of the rows corresponds to the bottom but I do not see columns or rows. Thank you.


VN Vignesh Natarajan Syncfusion Team May 18, 2018 12:35 PM UTC

Hi Scarpello, 
 
Thanks for using Syncfusion products. 
 
We have analyzed your query (not able to group the column from datatable) and we have prepared a sample using your code snippet. We are not able to reproduce the reported issue at our end. 
 
Kindly download the sample from below link 
 
 
Query2: “IsResponsive = "true" the total of the rows corresponds to the bottom but I do not see columns or rows” 
 
We are not able to understand your query properly. So kindly give us more details regarding your query along with following details to reproduce the reported issue at our end. 
 
1.       Share the full grid rendering code (since you have mentioned about isResponsive but your code does not contain definition about it) 
2.       Share the screenshot of script error in console window (if any) 
3.       Are you using ant type of adaptor in the sample. if so mention the type. 
4.       Try to reproduce the reported issue in provided sample. 
5.       Or try to provide issue reproducible sample. 
 
Note: from the code snippet shared we have found that you have updated the dataSource for one Grid (gr_Test) and updated the groupSettings for another grid (gr_TotaliAgenti). Please explain what you are trying to do?. 
   
  
Regards, 
Vignesh Natarajan 



CS Carmelo Scarpello May 18, 2018 02:03 PM UTC


Hello, in producing a clearer and more detailed code I have created new pages aspx and aspx.cs At the end I saw that the grid worked. Returning back to see the differences I saw what caused the error I had an extra link:
<script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </ script>
that I eliminated and this did not make me work the grid properly. Thanks anyway for the always very useful support. Greetings


VN Vignesh Natarajan Syncfusion Team May 21, 2018 04:13 AM UTC

Hi Scarpello, 

According to your update we suspect that you have referred multiple jQuery scripts in your sample which might be the cause of your issue. You have also mentioned that your issue has been resolved after removing the highlighted line.  

So please get back to us if you have further queries.  

Regards, 
Vignesh Natarajan. 


Loader.
Up arrow icon