MongoDB as grid datasource

Hi,
Could you please share some sample to use MongoDB list of documents as grid's datasource?
I am really struggling to get this to work with Blazor Grid.

Thanks!

11 Replies

RS Renjith Singh Rajendran Syncfusion Team April 29, 2020 12:19 PM UTC

Hi Adrian, 

Thanks for contacting Syncfusion support. 

We need more details to further proceed on this and provide you a solution as early as possible. Please share with us the following details for better assistance. 
  1. Share the video demo showing the problem you are facing.
  2. Share the details of script/exception if any occurred while running your application.
  3. Share your complete Grid rendering code, and also the Grid model codes. We need the details regarding how you are binding data to Grid(using DataSource property or SfDataManager)

And also, we request you to bind the “OnActionFailure” event to Grid. This event will be triggered for every failure in Grid. Please share the details you get in the “args” of this event handler for further analysis. 

The provided information will help us analyze the problem, and provide you a solution as early as possible. 

Regards, 
Renjith Singh Rajendran 



AD Adrian May 18, 2020 01:49 PM UTC

Thank you for your response. I have implemented OnActionFailure, as suggested, but I could not read anything from it as the exception occurs earlier, during early stage of Grid's rendering. Let me share some details.

Here is the runtime error:
blazor.server.js:15 [2020-05-18T13:39:32.539Z] Error: System.ArgumentException: An item with the same key has already been added. Key: Item
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at Syncfusion.Blazor.ModelMetadataProvider.ReadFromType(Type modelType)
   at Syncfusion.Blazor.Grids.GridAnnotation.MapAnnotation(GridColumn columns, Type type)
   at Syncfusion.Blazor.Grids.GridColumn.OnInitializedAsync()
   at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()

and the Blazor's page code itself:

@page "/grid_syncfusionBlazor_MongoDBSource"
@using Syncfusion.Blazor.Grids
@using MongoDB.Driver
@using MongoDB.Bson

<div class="col-lg-12 control-section">
    <div class="content-wrapper">
        <div class="row">
            <SfGrid DataSource="@dataSource">
                <GridEvents OnActionFailure="ActionFailureHandler" TValue="BsonDocument"></GridEvents>
                <GridColumns>
                    <GridColumn Field="_id" HeaderText="ObjectID"></GridColumn>
                </GridColumns>
            </SfGrid>
        </div>
    </div>    
    <p>@ActionFailureMessage</p>
</div>

@code{
    List<BsonDocumentdataSource { getset; }

    protected override void OnInitialized()
    {
            var client = new MongoClient();
            var database = client.GetDatabase("PoC");
            var collection = database.GetCollection<BsonDocument>("Customers");

            dataSource = collection.Find(new BsonDocument()).ToList();
    }

    public string ActionFailureMessage { getset; }
    public void ActionFailureHandler(FailureEventArgs args)
    {
        ActionFailureMessage = args.Error.ToString();
    }    
}



RS Renjith Singh Rajendran Syncfusion Team May 19, 2020 01:51 PM UTC

Hi Adrian, 

Thanks for your update. 

We have confirmed this as a defect Problem with using BsonDocument as model for Gridand logged a defect report for the same. At Syncfusion, we are committed to fixing all validated defects (subject to technological feasibility and Product Development Life Cycle ) and including the defect fix in our upcoming bi-weekly release which is expected to be rolled out by the mid of June 2020. 

You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.  

Please get back to us if you need further assistance. 
 
Regards,  
Renjith Singh Rajendran 



AD Adrian May 29, 2020 11:45 AM UTC

Thank you, I am looking forward to it.

In the meanwhile, is it possible to use DataManager to workaround the bug reported?


RS Renjith Singh Rajendran Syncfusion Team June 1, 2020 10:39 AM UTC

Hi Adrian, 

Thanks for your update. 

As a workaround, we suggest you to define a Product model for Grid’s datasource instead of using BsonDocument to overcome the reported problem. We have prepared a sample based on this scenario. Please download the sample form the link below, 
 
Please refer the codes below,  

 
List<Product> dataSource { getset; } 
 
public class Product{    public ObjectId Id { getset; }    [BsonElement("ProductId")]    public int ProductId { getset; }    [BsonElement("ProductName")]    public string ProductName { getset; }    [BsonElement("Price")]    public int Price { getset; }    [BsonElement("Category")]    public string Category { getset; }}

Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran 



AD Adrian July 6, 2020 06:55 AM UTC

Hi Renjith,
Do you have any update on this case? 




RS Renjith Singh Rajendran Syncfusion Team July 8, 2020 02:04 PM UTC

Hi Adrian, 

Sorry for the inconvenience caused. 

Due to some unforeseen circumstances, we could not include the fix for this issue in our latest Volume 2, 2020 main release. But we will fix this issue and this will be included in our upcoming patch release which is expected to be rolled out by the end of July, 2020. 

Until then we appreciate your patience. 

Regards, 
Renjith Singh Rajendran 



AD Adrian replied to Renjith Singh Rajendran August 3, 2020 12:31 PM UTC

Hi Adrian, 

Sorry for the inconvenience caused. 

Due to some unforeseen circumstances, we could not include the fix for this issue in our latest Volume 2, 2020 main release. But we will fix this issue and this will be included in our upcoming patch release which is expected to be rolled out by the end of July, 2020. 

Until then we appreciate your patience. 

Regards, 
Renjith Singh Rajendran 


Hi Renjith,
Could you please confirm if the defect was solved in the most recent July 2020 bugfix release?



RS Renjith Singh Rajendran Syncfusion Team August 4, 2020 12:31 PM UTC

Hi Adrian, 

We regret for the inconvenience caused. 

We are facing difficulties from our architectural level in fixing the reported problem from our side. So we could not include the fix in our July end bi-weekly release. But we will fix this issue and include this in our upcoming Volume 3, 2020 main release, which is expected to be rolled out in the month of September 2020. 

Until then we appreciate your patience.  

Regards,  
Renjith Singh Rajendran 



AD Adrian replied to Renjith Singh Rajendran October 12, 2020 11:29 AM UTC

Hi Adrian, 

We regret for the inconvenience caused. 

We are facing difficulties from our architectural level in fixing the reported problem from our side. So we could not include the fix in our July end bi-weekly release. But we will fix this issue and include this in our upcoming Volume 3, 2020 main release, which is expected to be rolled out in the month of September 2020. 

Until then we appreciate your patience.  

Regards,  
Renjith Singh Rajendran 


Hi Renjith,
Could you please confirm if the defect was solved in the most recent Volume 3, 2020 main release?



RS Renjith Singh Rajendran Syncfusion Team October 14, 2020 12:48 PM UTC

Hi Adrian, 

We regret for the inconvenience caused. 
 
Due to complexity involved in the implementation of promised issue, we have postponed the implementation of this to our upcoming bi-weekly release which is expected to be rolled out by the mid of November, 2020.      

You can track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.   

Till then we appreciate your patience.     

Regards,  
Renjith R 


Loader.
Up arrow icon