Telerik Forums
UI for ASP.NET MVC Forum
5 answers
186 views
I use that:
    @(Html.Kendo().Grid<Lorem.Core.DataModels.Contacts.DMConEmail>()
    .Name("ContactEmails")
    .Columns(columns =>
    {
        columns.ForeignKey(p => p.Type, Html.GetEnumList(typeof(Lorem.Core.DataModels.Contacts.DMConEmailType)));
        columns.Bound(p => p.Email);
        columns.Command(command => { command.Edit(); command.Destroy(); });
    })
    .ToolBar(toolbar => toolbar.Create())
    .Editable(editable => editable.Mode(GridEditMode.InLine))
    .DataSource(datasource => datasource.Ajax()
        .Model(model => model.Id(p => p.IdEmail))
        .Create(update => update.Action("EmailInsert", "Contact", new { idContact = Model.IdContact }))
        .Read(read => read.Action("EmailGetList", "Contact", new { idContact = Model.IdContact }))
        .Update(update => update.Action("EmailUpdate", "Contact"))
        .Destroy(update => update.Action("EmailDelete", "Contact"))
        ))

And I have a column that use an Enum to choose the email type. When I use that in a view, all is working fine. When I use it in an EditorTemplates I have this exception:
Ligne 1 : @model object
Ligne 2 :
Ligne 3 : @(
Ligne 4 : Html.Kendo().DropDownListFor(m => m)
Ligne 5 : .BindTo((SelectList)ViewData[ViewData.TemplateInfo.GetFullHtmlFieldName("") + "_Data"])

[ArgumentNullException: La valeur ne peut pas être null.
Nom du paramètre : source]
System.Linq.Enumerable.Select(IEnumerable`1 source, Func`2 selector) +4090943
Kendo.Mvc.UI.Fluent.DropDownListBuilder.BindTo(IEnumerable`1 dataSource) +88
ASP._Page_Views_Shared_EditorTemplates_GridForeignKey_cshtml.Execute() in c:\DCM\SVNPortailDCM\trunk\Softwares\Lorem\MVC\Views\Shared\EditorTemplates\GridForeignKey.cshtml:3
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +198
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +104
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +90
System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +235

Daniel
Telerik team
 answered on 04 Jul 2014
3 answers
1.0K+ views
Hi,

Sorry if I haven't searched enough to find a answer but can someone help me.

I put my application into production and all the dates seem to show the correct date minus 1 day. So instead of 1/6/2014 it shows 31/5/2014.

On local development PC the dates are correct and don't have this issue. All the functionality sorting filtering works but it just shows wrong date.

I use same browser  IE11  to view both sites.

I am using following to format date field in grid.

c.Bound(r => r.Effective_Status_Date).Width(150).Format("{0:dd/MM/yyyy}")

I tested the grid on the production server with a date field with no formatting and it shows the correct date if there is no formatting applied.

Production server is https:// but everything else seems to work except this date formatting.

Please let me know if there is a better way to get format  dd/mm/yyyy and not have this issue.

Thanks

Rob
Robert
Top achievements
Rank 1
 answered on 04 Jul 2014
1 answer
624 views
In the example code for the .cshtml file at http://demos.telerik.com/aspnet-mvc/grid/remote-data-binding there is read.Action() method near the end.  What are the parameters that are passed to it, in partciular the first one.  In the example the value is "Orders_Read".  Is this an entity?
Petur Subev
Telerik team
 answered on 04 Jul 2014
1 answer
71 views
Hi,
I have a datasource that contains an object (string) with a certain Order status code.
(e.g. "N", "A")

In my old asp.net application, I used to translate this code to a resource file in my application. (e.g. "N", becomes "New")
I used the onitemdatabound event (server side), to alter the contents of this cell.

What is the best approach to do this with asp.net mvc and kendo UI?
Would it be better that my WCF response already contains these translations? (however, I don't want to pass the culture to the WCF service I guess)
Or can kendo.ui Grid also change cell values (with some sort of jquery function that reads out a a resource file in my project?)

Thanks,
Nicolas
Petur Subev
Telerik team
 answered on 04 Jul 2014
1 answer
330 views
I have the following hierarchy grid that is server bound.  In the DetailTemplate I have tried 2 columns containing a Url.Action link.  The .ClientTemplate column does not render to the page as an anchor.  The .Template column has a syntax error at the @<text>.  How can I get a Url.Action column to render in the expansion hierarchy?

Thanks.
Dan

Code:
@model IEnumerable<EquipmentsSummary>
 
<div class="info-row">
    @(Html.Kendo().Grid(Model)
        .Name("EquipmentGrid")
        .Columns(columns =>
        {
            columns.Bound(e => e.ID).Hidden();
            columns.Bound(e => e.PatientId).Hidden();
            columns.Template(@<text>
                <a href="@Url.Action("EquipmentSettingEdit", Controllers.Employee, new { equipmentid=item.ID, settingid=0 }) "class='btn btn-sm'>Add</a>
                </text>).Width(75).Title("Add<br />Setting");
            columns.Bound(e => e.EquipName).Title("Item Name");
            columns.Bound(e => e.SerialNo).Title("Serial #");
            columns.Bound(e => e.AssetStatus).Title("Status");
            columns.Bound(e => e.AssetStatusDate).Title("Date");
        })
        .HtmlAttributes(new { style = "height: 500px;" })
        .Pageable(pageable => pageable
            .PageSizes(true).PageSizes(new int[] { 20, 50, 100 })
            .ButtonCount(5))
        .Sortable()
        .Filterable()
        .Scrollable()
        .DataSource(dataSource => dataSource.Server()
            .PageSize(20))
        .DetailTemplate(
            @<text>
                @(Html.Kendo().Grid(item.SettingItems)
                    .Name("Settings_" + item.ID)
                    .Columns(columns =>
                    {
                        columns.Bound(s => s.SettingID).Hidden();
                        columns.Bound(s => s.EffectiveDate).Title("Date").Format("{0:g}");
                        columns.Bound(s => s.AssetStatus).Title("Status");
                        columns.Bound(s => s.Clinician);
                        columns.Bound(s => s.SettingID).ClientTemplate(
                            "<a href='" + Url.Action("EquipmentSettingEdit", Controllers.Employee) + "/?equipmentid=#=item.ID#&settingid=#=SettingID#'" + "class='btn btn-sm'>Details</a>"
                            ).Width(75).Title("").Filterable(false);
                        columns.Template(
                            @<text>
                            <a href='@Url.Action("EquipmentSettingCopy", Controllers.Employee)' class='btn btn-sm'>Copy</a>
                            </text>).Width(75).Title("").Filterable(false);
                    })
                    .DataSource(dataSource =>dataSource.Server().PageSize(20))
                         
                    .Pageable(pageable => pageable
                        .PageSizes(true).PageSizes(new int[] { 20, 50, 100 })
                        .ButtonCount(5))
                    .Sortable()
                    .Filterable()
                    .Scrollable()
                )
            </text>
        )
        .RowAction(row =>
        {
            if (row.Index == 0)
            {
                //row.DetailRow.Expanded = true;
            }
            else
            {
                var requestKeys = Request.QueryString.Keys.Cast<string>();
                var expanded = requestKeys.Any(key => key.StartsWith("Settings_" +
                    row.DataItem.ID) ||
                    key.StartsWith("SettingItems_" + row.DataItem.ID));
                row.DetailRow.Expanded = expanded;
            }
        })
         
    )
 
</div>
Petur Subev
Telerik team
 answered on 03 Jul 2014
4 answers
69 views
Hi There,

I am currently working on Kendo Grid. I have implemented ajax binding with default paging using the below link
http://docs.telerik.com/kendo-ui/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/ajax-binding

In ie10 i am getting a javascript error in aspnetmvc.min.js file before the pageload. once page loaded everything is working perfectly.
below is the code i have used.

I am using  Kendo.MVC.dll and KendoAjaxBinding.Model.dll of version v4.0.30319

.cshtml
--------
<div>
@(Html.Kendo().Grid<KendoUIAjaxBinding.Model.PM_ANO>()

.Name("grid")
.DataSource(dataSource => dataSource

.Ajax()

.Read(read => read.Action("Products_Read", "Home")

.Data("productsReadData")
)
)
.Columns(columns =>
{
columns.Bound(anomaly => anomaly.GOD);
columns.Bound(anomaly => anomaly.VER);
// Create a column bound to the ProductID property
columns.Bound(anomaly => anomaly.C_ANO);
// Create a column bound to the ProductName property
columns.Bound(anomaly => anomaly.Y_ANO);
// Create a column bound to the UnitsInStock property
columns.Bound(anomaly => anomaly.Z_REP_AUTO);
})
.Pageable(x => x.PageSizes(true)) // Enable paging
.Sortable() // Enable sorting
)
</div>



in Layout page i have rendered like this
----------------------------------------
<head>
<meta charset="utf-8" />
<title>@ViewBag.Title - My ASP.NET MVC Application</title>
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<meta name="viewport" content="width=device-width" />


<script src="~/Scripts/jquery-1.7.1.js"></script>
<script src="~/Scripts/Kendo/kendo.web.min.js"></script>
<script src="~/Scripts/Kendo/kendo.aspnetmvc.min.js"></script>

</head>

controller code
------------------
public JsonResult

Products_Read([DataSourceRequest]DataSourceRequest request, string firstName, string lastName)
{

var _context = new E2A_GUIEntities();

IQueryable<PM_ANO> anomaly = _context.PM_ANO;


var total = anomaly.Count();

if (request.Page > 0)
{
anomaly = anomaly.OrderBy(a => a.C_ANO).Skip((request.Page - 1) * request.PageSize);
}
anomaly = anomaly.Take(request.PageSize);
var result = new DataSourceResult()
{
Data = anomaly, // Process data (paging and sorting applied)
Total = total // Total number of records
};

return Json(result, JsonRequestBehavior.AllowGet);

}

Please help me in resolving this.


Thanks and Regards,
Gangadhar.

Rosen
Telerik team
 answered on 03 Jul 2014
9 answers
1.1K+ views
I use a Grid in a view to show this structure (EntityFramework):
Class1 {
     Name;
     ContactProperty: Contact {
          Name;
          Property2: List<DMConEmail> {
               Type
               Email
          }
     }
}

I first use a flat view to show and edit data and use a Grid with ajax to show the Property2 list:
        @(Html.Kendo().Grid<Lorem.Core.DataModels.Contacts.DMConEmail>()
    .Name("Contact_Emails")
    .Columns(columns =>
    {
        columns.Bound(p => p.Type);
        columns.Bound(p => p.Email);
        columns.Command(command => { command.Edit(); command.Destroy(); });
    })
    .ToolBar(toolbar => toolbar.Create())
    .Editable(editable => editable.Mode(GridEditMode.InLine))
    .DataSource(datasource => datasource.Ajax()
        .Model(model => model.Id(p => p.IdEmail))
        .Create(update => update.Action("EmailInsert", "Contact", new { idContact = Model.IdContact }))
        .Read(read => read.Action("EmailGetList", "Contact", new { idContact = Model.IdContact }))
        .Update(update => update.Action("EmailUpdate", "Contact"))
        .Destroy(update => update.Action("EmailDelete", "Contact"))
        ))

All is working fine for this.

For re-usability, I put the contact model class in an EditorTemplates and when I click the edit button in a grid row, I lost all the field content.
    @Html.EditorFor(m => m.ContactProperty, "DMConEmail")

Summary:
When I use a flat view, the editing line in the grid keep values in texbox. When I use the grid in an EditorTemplate, the editing line textbox was empty.

Thanks for the help.



Petur Subev
Telerik team
 answered on 03 Jul 2014
1 answer
995 views
Hi,

I want to create dashboard with drag and drop widgets.  Users can add, delete and move available widgets. Please provide me starting point how do I achieve desired functionality.

Thanks in advance.
Sebastian
Telerik team
 answered on 03 Jul 2014
1 answer
74 views
The attached image displays the results from including the first two examples from http://docs.telerik.com/kendo-ui/api/web/grid.  (I added a couple of rows to the data source in the first one).

Why are the even number rows displaying the age value in the name column right next to the name?

How do I fix this?
Dimiter Madjarov
Telerik team
 answered on 03 Jul 2014
1 answer
163 views

The first example on http://docs.telerik.com/kendo-ui/api/web/grid has the following line: 

altRowTemplate: kendo.template($("#alt-template").html())

Does this row contain information about the colors used in the alternating rows?  Right now it displays them in white and grey.  If I wanted to change the colors how would I go about doing so?




Dimiter Madjarov
Telerik team
 answered on 03 Jul 2014
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
ComboBox
Upload
MultiSelect
ListView
Window
TabStrip
Menu
Installer and VS Extensions
Spreadsheet
AutoComplete
TreeList
Gantt
PanelBar
NumericTextBox
Filter
ToolTip
Map
Diagram
Button
PivotGrid
Form
ListBox
Splitter
Application
FileManager
Sortable
Calendar
View
MaskedTextBox
PDFViewer
TextBox
Toolbar
MultiColumnComboBox
Dialog
DropDownTree
Checkbox
Slider
Switch
Notification
Accessibility
ListView (Mobile)
Pager
ColorPicker
DateRangePicker
Wizard
Security
Styling
Chat
DateInput
MediaPlayer
TileLayout
Drawer
SplitView
Template
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Licensing
Rating
ScrollView
ButtonGroup
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
DateTimePicker
AppBar
BottomNavigation
Card
FloatingActionButton
Localization
MultiViewCalendar
PopOver (Mobile)
Ripple
ScrollView (Mobile)
Switch (Mobile)
PivotGridV2
FlatColorPicker
ColorPalette
DropDownButton
AIPrompt
PropertyGrid
ActionSheet (Mobile)
BulletGraph
Button (Mobile)
Collapsible
Loader
CircularGauge
SkeletonContainer
Popover
HeatMap
Avatar
ColorGradient
CircularProgressBar
SplitButton
StackLayout
TimeDurationPicker
Chip
ChipList
DockManager
ToggleButton
Sankey
OTPInput
ChartWizard
SpeechToTextButton
InlineAIPrompt
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
AICodingAssistant
+? more
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?