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. Image for the cookie policy date

Filtering and Dropdown in grid with key = Guid

When using a childgrid with the usage of Guid in Grid and ChildGrid the functions do not work as expected.

Child grid data functionn 

DataManager dataManager;
DataOperations operation = new DataOperations();

// this has to be done else a conversion error occures.
dataManager.Where[0].value = Guid.Parse(dataManager.Where[0].value.ToString());

data = operation.PerformWhereFilter(data, dataManager.Where, dataManager.Where[0].Operator);

Also a problem with a dropdown in the grid with Guid as ForeignKey. It does not show the dropdown list and the value (same issue???)

The data delivered is a guid and not a string.

1 Reply

KK Karthick Kuppusamy Syncfusion Team July 5, 2016 01:23 PM UTC

Hi Eddy,  
 
Query 1: This has to be done else a conversion error occurs.  
  
We have analyzed your code example and we are able to reproduce the reported issue.  Normally when using a GUID column it will serialize the value as string while returning the data from controller to view.  So that you have faced an exception while binding the data. To overcome this please use the same code that you have used to convert string value to Guid.  
 
Please refer the below example  
 
[controller.cs]    
 DataOperations operation = new DataOperations();  
              
            if (dm.Where != null && dm.Where.Count > 0) //Filtering  
            {  
                dm.Where[0].value = Guid.Parse(dm.Where[0].value.ToString());  
                  
                  data = operation.PerformWhereFilter(data, dm.Where, dm.Where[0].Operator);  
              }              
            int count = data.Cast<Child>().Count();  
            
            return Json(new { result = data, count = count },JsonRequestBehavior.AllowGet);  


 
Query 2: Also a problem with a dropdown in the grid with Guid as ForeignKey  
  
      We are not able to reproduce the reported issue. We have checked by binding the ForeignKey value to the guid column in childgrid. The data bind to the dropdown list and the value are rendered correctly. Please refer the below code example  
  
[GridFeatures.cshtml]  
.ChildGrid(child =>  
                               {  
                                       
                                  .Columns(col =>  
                         {  
  
col.Field("guid").HeaderText("guid").ForeignKeyField("guid").ForeignKeyValue("customer").DataSource((IEnumerable<object>)ViewBag.datasource1).EditType(EditingType.Dropdown).TextAlign(TextAlign.Left).Width(90).Add();  
  
                          })  
  
  
If you still face the issue please get back to us with the following details,  
  
1.       Have you used any adaptor for child grid and parent grid to bind the data?  
2.       In which column for childgrid you have bind a ForeignKey?  
3.       Is there any script error or exception thrown in your project for not binding the datasource for dropdown control? If so, attach a screenshot for your stack trace.     
4.       Share the video to show the issue.  
5.       Issue replication procedure.  
6.       An issue reproducing sample if possible or replicate the issue in the following sample  
7.       Share the grid rendering code and server side code  
  
We have also prepared a sample that can be downloaded from the below link,  
  
  
The provided information will help us to analyze the issue and provide you the response as early as possible.  
  
Regards, 
K.Karthick. 


Loader.
Live Chat Icon For mobile
Up arrow icon