This question is locked. New answers and comments are not allowed.
Hi there,
I have this view model:
public class ConfigViewModel
{
[ScaffoldColumn(true)]
[UIHint("ReadOnlyString")]
public string DataTypeFullName { get; set; }
[ScaffoldColumn(true)]
[UIHint("ReadOnlyString")]
public string PropertyName { get; set; }
[Display(Description = "Category")]
[UIHint("ReadOnlyString")]
public string LogicalAreaTypeName { get; set; }
[UIHint("ReadOnlyString")]
public string DisplayName { get; set; }
public object CurrentValue { get; set; }
}
And using ajax binding to grid like this:
<% Html.Telerik().Grid<JService.Services.Configuration.ConfigViewModel>()
.Name("ConfigurationsGrid")
.DataBinding(dataBinding => dataBinding
.Ajax()
.Select("ConfigurationGridIndex", "Configuration", new { area = "System", format = "json" })
.Update("ConfigurationGridUpdate", "Configuration", new { area = "System", format = "json" })
)
.DataKeys(keys =>
keys.Add(u => u.PropertyName))
.Columns(columns =>
{
columns.Bound(u => u.LogicalAreaTypeName).Title("Category").ReadOnly();
columns.Bound(u => u.DisplayName).Title("Item").ReadOnly();
columns.Bound(u => u.CurrentValue).Title("Current Value").Sortable(false);
columns.Command(commands =>
{
commands.Edit();
}).Title("Commands");
})
.Pageable(pager => pager.PageSize(10))
.Sortable(s=> s.SortMode(GridSortMode.SingleColumn))
.Groupable()
.Filterable()
.Render();
%>
The problem I have is when in inline edit mode, the current value column is empty. No edit controls at all. So I thought I should add an object.ascx to EditorTemplates like below:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<object>" %>
<% if(Model == null) { %>
hi there
<%} else if(Model.GetType() == typeof(string)) { %>
<%: Html.EditorFor(e => e.ToString()) %>
<%} else if(Model.GetType() == typeof(int)) { %>
<%: Html.EditorFor(e => (int)e) %>
<%} else if(Model.GetType() == typeof(DateTime)) { %>
<%: Html.EditorFor(e => (DateTime)e) %>
<%} else if(Model.GetType() == typeof(bool)) { %>
<%: Html.EditorFor(e => (bool)e) %>
<%} else { %>
<%: Html.EditorFor(e => e.ToString()) %>
<% } %>
But the Model is always null, and so displaying the debug message "hi there". Any ideas on how I can get this edit mode working for an object datatype?
Cheers,
Sandy.
I have this view model:
public class ConfigViewModel
{
[ScaffoldColumn(true)]
[UIHint("ReadOnlyString")]
public string DataTypeFullName { get; set; }
[ScaffoldColumn(true)]
[UIHint("ReadOnlyString")]
public string PropertyName { get; set; }
[Display(Description = "Category")]
[UIHint("ReadOnlyString")]
public string LogicalAreaTypeName { get; set; }
[UIHint("ReadOnlyString")]
public string DisplayName { get; set; }
public object CurrentValue { get; set; }
}
And using ajax binding to grid like this:
<% Html.Telerik().Grid<JService.Services.Configuration.ConfigViewModel>()
.Name("ConfigurationsGrid")
.DataBinding(dataBinding => dataBinding
.Ajax()
.Select("ConfigurationGridIndex", "Configuration", new { area = "System", format = "json" })
.Update("ConfigurationGridUpdate", "Configuration", new { area = "System", format = "json" })
)
.DataKeys(keys =>
keys.Add(u => u.PropertyName))
.Columns(columns =>
{
columns.Bound(u => u.LogicalAreaTypeName).Title("Category").ReadOnly();
columns.Bound(u => u.DisplayName).Title("Item").ReadOnly();
columns.Bound(u => u.CurrentValue).Title("Current Value").Sortable(false);
columns.Command(commands =>
{
commands.Edit();
}).Title("Commands");
})
.Pageable(pager => pager.PageSize(10))
.Sortable(s=> s.SortMode(GridSortMode.SingleColumn))
.Groupable()
.Filterable()
.Render();
%>
The problem I have is when in inline edit mode, the current value column is empty. No edit controls at all. So I thought I should add an object.ascx to EditorTemplates like below:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<object>" %>
<% if(Model == null) { %>
hi there
<%} else if(Model.GetType() == typeof(string)) { %>
<%: Html.EditorFor(e => e.ToString()) %>
<%} else if(Model.GetType() == typeof(int)) { %>
<%: Html.EditorFor(e => (int)e) %>
<%} else if(Model.GetType() == typeof(DateTime)) { %>
<%: Html.EditorFor(e => (DateTime)e) %>
<%} else if(Model.GetType() == typeof(bool)) { %>
<%: Html.EditorFor(e => (bool)e) %>
<%} else { %>
<%: Html.EditorFor(e => e.ToString()) %>
<% } %>
But the Model is always null, and so displaying the debug message "hi there". Any ideas on how I can get this edit mode working for an object datatype?
Cheers,
Sandy.