FlexGrid - white page

Posted by: software on 15 September 2021, 11:25 pm EST

    • Post Options:
    • Link

    Posted 15 September 2021, 11:25 pm EST

    Hi,

    I have a lot of problem for use your component… :wink:

    Model Channels (generate by entity framework)

    
    public partial class Channels
     {
    	public int MapChannelsID { get; set; }
            public string Name { get; set; }
            public string ServiceReference { get; set; }
            public int TypeId { get; set; }
            public Nullable<int> MediaId { get; set; }
    }
    
    

    Controller : ChannelController

    
    public class ChannelsController : Controller
    {
     	private dbentitites db = new dbentitites();
            // GET: Channels
            public ActionResult Index()
            {
                return View(db.Channels);
            }
    }
    
    

    View : index

    
    @using C1.Web.Mvc.Fluent
    @using C1.Web.Mvc.Grid
    @using Record.Models
    @model IEnumerable<Record.Models.Channels>
    
    @{
        ViewBag.Title = "Chaîne - Liste";
        Layout = "~/Views/Shared/_Layout.cshtml";
    }
    
    @(Html.C1().FlexGrid<Channels>().Id("gsFlexGrid")
        .IsReadOnly(true)
        .AllowSorting(true)
        .Bind(Model)
        .AutoGenerateColumns(true)
        )
    
    

    Where is my error? Because I have always a blank page…

    Thank you

    Regards

  • Posted 18 September 2021, 3:53 pm EST

    Hi,

    We are not sure what is the issue cause. Here are the possible issue causes:

    1. The Resource is not registered correctly.

      Please refer to the following documentation link for reference:

      https://www.grapecity.com/componentone/docs/mvc/online-mvc/UsingVSTemplate.html

      https://www.grapecity.com/componentone/docs/mvc/online-mvc/RegisteringResources.html

    2. If the FlexGrid is rendered and the data is not loading correctly, in that case, the issue might be with the Data fetching from the EntityFramework.

    3. Also, check the console window for the browser and if you are getting any issues.

    Hope it helps!

    Regards,

    Manish Gupta

  • Posted 19 September 2021, 6:26 pm EST

    My code

    Index View

    
    @model IEnumerable<ScheduleRecordings.Models.MapChannels>
    @(Html.C1().FlexGrid<MapChannels>
        ().Id("fGRCView").AutoGenerateColumns(false).AllowAddNew(false).Width("100%")
        .AllowSorting(true).CssClass("grid")
        .SelectionMode(C1.Web.Mvc.Grid.SelectionMode.Row)
        .Columns(columns => columns
                .Add(c => c.Binding("MapChannelsID").Header("Id"))
                .Add(c => c.Binding("Name").Header("Nom"))
                .Add(c => c.Binding("ServiceReference").Header("Service Réf.").Width("500"))
                .Add(c => c.Binding("MapTypes.Name").Header("Type").Width("500"))
            )
        .Bind(Model)
        )
    
    
    

    controller

    
    private ScheduleRecDBEntities db = new ScheduleRecDBEntities();
            // GET: Channels
            public ActionResult Index()
            {
                return View(db.MapChannels);
            }
    
    

    My code is not correct?

  • Posted 20 September 2021, 8:12 pm EST

    Hi,

    If I remove the bind… I see the columns…

    I don’t understand…

  • Posted 20 September 2021, 10:48 pm EST

    Apparently the problem is Entity FrameWork

    Because de FlexGrid wait a list of object and EF send a dynamic list of this object (the type is not really the same)

    Regards

  • Posted 20 September 2021, 11:26 pm EST

    Hello,

    We could not find any issue with the above-provided code snippet. Kindly provide information on the following points along with a sample depicting the issue so that we may debug it and reply accordingly.

    • Whether any error is being shown on the console window of the browser?
    • Kindly check if the data is being fetched properly from Entity Framework.

    Please refer to the sample below,

    Regards

    Dushyant Sharma

    FlexGrid.zip

  • Posted 21 September 2021, 12:32 am EST - Updated 29 September 2022, 1:44 am EST

    The FlexGrid need this object type [MapChannels]

    And EF give a list with [Dynamic.MapChannels]

    I need that EF give a list with MapChannels Type

  • Posted 22 September 2021, 6:42 pm EST

    Hello,

    The above issue is occurring because Entity Framework often creates instances of a dynamically generated derived type that acts as a proxy for the entity. This mechanism is often used to support the lazy loading of relationships.

    To prevent EF from creating proxy instances, we may set the ProxyCreationEnabled flag to false.

    Please refer to the below link for more information:

    https://docs.microsoft.com/en-us/ef/ef6/fundamentals/proxies

    Hope this clarifies the above issue.

    Regards

    Dushyant Sharma

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels