Datagridfor display none?

Mar 7, 2012 at 3:54 PM
Edited Mar 7, 2012 at 3:55 PM

Hi,

I use the datagrid for in a readonly situation and this worked before, but at the moment I get a display none in my html

<tr id="Networks___0___Item_Value_Display_Container" style="display: none;"> 

This is my razor code:

@Html.DataGridFor(x => x.NetworksItemContainerType.trnull"NetworkItemDisplay"nullnull, itemCss: "normalRow", altItemCss: "alternateRow")
Any clue what is happening?
Patrick
Coordinator
Mar 8, 2012 at 4:22 PM

style="display: none;   ....is put on a display template when the row is in edit mode BUT ALSO BEFORE THE GRID IS INITIALIZED. so it is normal that you find style="display: none; in the page sources. When the grid is initialized the style="display: none;  of each grid row is removed.

 

So if your grid doesn't appear probably there is a previous javascript error that prevent grid inizialization. So rows continue to be invisible. Another possibility is that you forget the Mvc Controls Toolkit js file...:)

 

Anyway 

@Html.DataGridFor(x => x.Networks, ItemContainerType.tr, null, "NetworkItemDisplay", null, null, itemCss: "normalRow", altItemCss: "alternateRow")

is working for me!! If you need to convince yourself (..sometime one want to be 1000% sure) delete the edit and add templates in the example that comes 
with the binaries...and you will see that it works.
Mar 8, 2012 at 4:41 PM

Damn, your good ;)

 

<script src="/Content/Scripts/MVCControlToolkit.Controls-1.8.0.-min.js" type="text/javascript"> </script>

 

see the extra - sign before the min.

 

Thanks m8

Patrick

Jul 2, 2012 at 3:09 AM
@using MVCControlsToolkit.Controls;

@model Galaxy.Web.Models.ItemModel

@ViewData["Content"]
@Html.ColumnNameFor(m => m.Name)@Html.ColumnNameFor(m => m.Level)

hi

I have a prob. using the DataGridFor<>

Item model:

 

 

public class ItemModel
{
  public string Name{get;set;}
  public int Level{get;set;}
}

View model:

 

 

public class ViewModel
{
  public List<Tracker<ItemModel>> Items{get;set;}
}

View Controller:

public ActionResult Index(){
  ViewModel model = new ViewModel();
  return View(model);
}

 

 

 

 

 

View:

@using MVCControlsToolkit.Controls;

@model Galaxy.Web.Models.ViewModel
           
@using (Html.BeginForm("Index", "Controller"))
{
    <div>
        <div>
            @Html.DataGridFor(m => m.Data, ItemContainerType.tr, null, "DisplayTemplate", "GridTemplate")
        </div>
    </div>
}

 

 

Display template:
@using MVCControlsToolkit.Controls;

@model Galaxy.Web.Models.ItemModel

<td>
    @Html.DisplayField(m => m.Name)
</td>
<td>
    @Html.DisplayField(m => m.Level)
</td>
  

  
Grid template:
@using MVCControlsToolkit.Controls;

@model Galaxy.Web.Models.ItemModel

<td><strong>
    @Html.ColumnNameFor(m => m.Name)
</strong>
</td>
<td><strong>
    @Html.ColumnNameFor(m => m.Level)
</strong>
</td>
 
When I run this I get the following error in the view 
 '$' is not defined
  

<

 

table

 

 

<tr

 

 

<td><strong>Name</strong></td

 

 

<td><strong>Level</strong></td

 

 

</tr

 

 

</

 

table

 

 

<script language='javascript' type

 

 

var Data_AllNormal=null

 

var Data_validationType = 'UnobtrusiveClient'

 

var Data_Css = ''

 

var Data_AltCss = ''

 

var Data_FatherItems = null

 

var Data_FieldsToUpdate = null

 

</script

 

 

 

<script language='javascript' type

 

$(document).ready(

function

 

"MvcControlsToolkit_DataGridApplyStyles('Data');"

 

, 0);

 

});

<

()

{setTimeout(

 

 

='text/javascript'>

 

>

;

 

 

;

 

 

;

 

 

;

 

 

;

 

 

;

 

 

 

='text/javascript'>

 

>

 

>

 

>

 

>

 

>

 

>

  

Jul 2, 2012 at 4:16 AM

I solved the prob.

In my _Layout.c5html file, I was add the javascript files in the bottom by moving the add to the header the prob. was solved.