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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Two simple questions about the Grid declaration in Razor

Thread ID:

Created:

Updated:

Platform:

Replies:

131887 Aug 1,2017 07:16 PM UTC Aug 2,2017 04:58 PM UTC ASP.NET MVC 1
loading
Tags: Grid
Samuel Otero
Asked On August 1, 2017 07:16 PM UTC

I just have a couple of questions regarding the grid declaration in Razor.

Consider this piece of code:

@(Html.EJ().Grid<EmployeeView>("CustomGrid") 
        .Datasource((IEnumerable<object>)ViewBag.datasource1) 
        .AllowPaging() 
        .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.ExternalFormTemplate).ExternalFormTemplateID("#template"); }) 

1. What is "EmployeeView"?
2. Do I need to provide a datasource, considering that the grid would be empty when the page renders and I am the one who are going to fill it with data?

Thank you!!!

PD: This is a follow up from this thread.

Farveen Sulthana Thameeztheen Basha [Syncfusion]
Replied On August 2, 2017 04:58 PM UTC

Hi Samuel, 

Thanks for contacting Syncfusion Support. 

Query #1 :- What is “EmployeeView” ? 

You can create the view-model class  like “EmployeeView” or “OrdersView”  as a type of EJ() and bind to the Grid.  EmployeeView is the model class that we have bind to the Grid. 



Query #2 :- Do I need to provide a datasource, considering that the grid would be empty when the page renders and I am the one who are going to fill it with data? 
 
Initially we have rendered the Grid with empty dataSource and update the Grid dynamically by using “dataSource” method of the Grid. Please refer to the code example:- 

<button id="btn" onclick="myfunction()">Datasource</button> <br /> 
 
@(Html.EJ().Grid<object>("FlatGrid") 
            .AllowPaging() 
             .Columns(col => 
            { 
            col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(100).Add(); 
            col.Field("CustomerID").HeaderText("Customer ID").Width(100).Add(); 
              .   .    . 
            
        }) 
   ) 
 
<script type="text/javascript"> 
        function myfunction() { 
            var grid = $("#FlatGrid").ejGrid("instance"); 
            var dataManager = ej.DataManager("http://mvc.syncfusion.com/Services/Northwnd.svc/Orders"); 
            grid.dataSource(dataManager); 
 
        } 
    </script> 
      

Please refer to the documentation link :- 



Regards, 

Farveen sulthana T 


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.

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

;