Telerik Forums
UI for ASP.NET MVC Forum
1 answer
318 views

Hello.

 I have been googling this today and I haven't come up with a decent example.  I have grid with a popup editor.  I can set the size of the grid, but the controls are all left justified which makes for a very large form that is not very responsive.  Are there any examples of a multi-column popup editor?  I know a large vertical form won't cut it for the boss.  I might be able to convince him popups are not bad if I can do a multi column layout.  I tried multiple things...fieldsets...rows...spans all using the bootstrap grid to no avail.  Any suggestions?  I guess I could use a bootstrap modal instead.

Dimiter Madjarov
Telerik team
 answered on 27 Oct 2015
1 answer
45 views

This does not appear possible with the MVC/Kendo Grid.  I am wondering why this was removed.

I would like to see this replaced if at all possible.  It was really handy.

Thanks.

Pavlina
Telerik team
 answered on 26 Oct 2015
1 answer
252 views
How would I go about printing the header of my grid on every page? 
Maria Ilieva
Telerik team
 answered on 26 Oct 2015
3 answers
670 views

I have a model with an enum as a data type on a property.  In the grid I want to show an image representation for this enum.  Whats the best way to do this?

I've tried using the ClientTemplate to do this.  I'm not sure what I need.  I have tried the following without success:

@(Html.Kendo().Grid<BatchEditModel>()
        .Name("mygrid")
        .Columns(columns =>
        {
            columns.Bound(bem => bem.MyInfo.Number).ClientTemplate(
                    "# if (MyStatus == " + MyStatusConstants.Complete + ") { #
                    <span class="icon-oo-my-img-32" style="font-size: 1.2em; color: green"></span>
                    "# } #"
                    "# else if (MyStatus == " + MyStatusConstants.PWHTRequired + ") { #"
                    <span class="icon-oo-my-img-32" style="font-size: 1.2em; color: darkcyan"></span>
                    "# } #"
                    "# else if (MyStatus == " + MyStatusConstants.Myed + ") { #"
                    <span class="icon-oo-my-img-32" style="font-size: 1.2em; color: blue"></span>
                    "# } #"
                )

This has errors in the razor page.  I had the all the text wrapped in quotes and used + to concatenate them. 

The question is, I have an enum as a value, but I want to display an image - which is a custom glyph icon on the span.  What is the best way to implement this?

Thanks

Andez

Dimiter Madjarov
Telerik team
 answered on 23 Oct 2015
4 answers
162 views

Hi.  I have 2 screen with a Telerik MVC grid.  First one is for Orders and second one for OrderDetails.  I use server binding.

The first one works fine.  It shows Orders data in the grid.  Each row has a Details button and when I click on the button, the second screen shows up with the OrderDetails data of the Order data you selected  in the grid.  Here each row has a Edit button that is supposed to perform inline editing.

At this point, the URL is http://myweb.com/Order/Details/123.  123 is the OrderId in the Orders table.

The problem happens when I click on Edit button for the row data.  It does a GET request with OrderDetailId automatically.  The page expects OrderId not OrderDetailId.

So, at this point, the page expects http://myweb.com/Order/Details/##OrderId## but the grid does http://myweb.com/Order/Details/##OrderDetailId##.

How should I handle this case?  Could I manage what URL format the grid uses for the Edit button?

Rosen
Telerik team
 answered on 23 Oct 2015
1 answer
395 views

Hi,

 I am trying to create a grid with one column to return a result similar to your example here: http://demos.telerik.com/kendo-ui/grid/rowtemplate.  I am using the server-side RowTemplate code such as...

            @(Html.Kendo().Grid(Model.Results)
                .Name("Components")
                .RowTemplate(grid =>
                    @<text>
                    <tr>
                        <td>
                            ID: @item.ComponentID<br>

                            Name: @item.Name

                            ... etc
                        </td>
                    </tr>
                    </text>
                )

            .DataSource(d => d.Ajax().ServerOperation(false))
            .Pageable(pageable => pageable
                .Refresh(true)
                .PageSizes(true)
                .ButtonCount(5))
            )

 I am basing my code on this example:

@model IEnumerable<Product>@(Html.Kendo().Grid(Model).Name("grid")

    .RowTemplate(grid => @<text><div>Product Name: @product.ProductName</div><div>Units In Stock: @product.UnitsInStock</div></text>))

​The output completely ignores the rowFormat and prints every field in the model object as a separate column (see attached photo).

I have tried almost everything - client templates, etc.  Nothing stops every column from being displayed.

 Any ideas would be appreciated.

Dimiter Madjarov
Telerik team
 answered on 22 Oct 2015
1 answer
414 views

I have two classes Category and Product and I want to expend products when users click a category node on the treeview.

My View is as follows:

    <h2>Index</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
<div class="row">
    <div class="col-md-3">
        <label class="k-label-top">TreeView</label>
        @(Html.Kendo().TreeView().Name("treeview")
        .DataSource(datasource => datasource
                            .Read(read => read.Action("Categories", "Categories"))
            ).DataTextField("Name")
        )
    </div>
    
</div>

 

Controller

        public ActionResult Categories(int? id)
        {
            var model = db.Categories
                .Where(p => p.Id == id.Value || p.Id == null)
                .Select(p => new {
                    id = p.Id,
                    Name = p.Name,
                    hasChildren = p.Products.Any()
                });
            return this.Json(model, JsonRequestBehavior.AllowGet);
        }

Categories Class

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace EmployeeTreeView.Models
{
    public class Category
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public virtual ICollection<Product> Products { get; set; }
    }
}

 

Products Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace EmployeeTreeView.Models
{
    public class Product
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public virtual Category Category { get; set; }
        public int CategoryId { get; set; }
    }
}

 When I remove the where clause in the controller the parent node just loops over and over again, but no child nodes are displayed.

Kabelo
Top achievements
Rank 1
 answered on 22 Oct 2015
1 answer
390 views

I have a checkbox (chkRecurring) in the custom editor of the scheduler. I need to show/hide a div (divRecurring) clicking the checkbox. I wrote jquery click event but it doesn't work. And it doesn't throw any error in firebug or any other browser console.

 

@(Html.Kendo().Scheduler<TaskViewModel>()
                                    .Name("schedulerJob")
                                    .Date(DateTime.Today)
                                    .StartTime(7, 0, 0)
                                    .Height(700)
                                    .Views(views =>
                                    {
                                        views.DayView();
                                        views.WeekView();
                                        views.TimelineView(v => v.Selected(true));
                                    })
                                    .Events(e =>
                                    {
                                        e.Edit("schedulerJob_edit");
                                        e.Navigate("schedulerJob_navigate");
                                        e.Remove("schedulerJob_remove");
                                        e.Save("schedulerJob_save");
                                        e.DataBinding("schedulerJob_dataBinding");
                                        e.DataBound("schedulerJob_dataBound");
                                    })
                                    .Group(group => group.Resources("Techs").Orientation(SchedulerGroupOrientation.Vertical))
                                    .Resources(resource =>
                                    {
                                        resource.Add(m => m.TechName)
                                            .Title("Techs")
                                            .Name("Techs")
                                            .DataTextField("TechName")
                                            .DataValueField("emm_code")
                                            .DataSource(d => d.Read("Techs", "JOBS"));
                                    })
                                    .DataSource(d => d
                                        .Model(m =>
                                        {
                                            m.Id(r => r.emm_code);
                                        })
                                        .ServerOperation(true)
                                        .Read(r => r.Action("JobSchedule_Read", "JOBS").Data("passFilter"))
                                        .Create("JobSchedule_Create", "JOBS")
                                        .Update("JobSchedule_Update", "JOBS")
                                        .Destroy("JobSchedule_Delete", "JOBS")
                                    )
                                    .Editable(e => {
                                        e.TemplateId("schedulerJobEditor").Window(w => w.Title("Time Slot Reservation").Name("schedulerJobEditor"));
                                    })
                                )

 

<script id="schedulerJobEditor" type="text/x-kendo-template">
                                    <div>
                                        <table style="border-collapse: initial;">
                                            <tr>
                                                <td align="right">
                                                    <label for="Start">Job Date:</label>
                                                </td>
                                                <td>
                                                    <input type="text" id="jobDateTextbox" class="k-input k-textbox" name="start" data-bind="value: StartViewDate" style="border-width: 0px;" disabled="disabled">
                                                </td>
                                                <td align="right">
                                                    <label for="ReservedDate">Reserved On:</label>
                                                </td>
                                                <td>
                                                    <input type="text" id="reservedDateTextbox" class="k-input k-textbox" name="reservedDate" data-bind="value: ReservationViewDate" style="border-width: 0px;" disabled="disabled">
                                                </td>
                                            </tr>
 
                                            <tr>
                                                <td align="right">
                                                    <label for="Start">Job Time:</label>
                                                </td>
                                                <td>
                                                    <input type="text" id="jobTimeTextbox" class="k-input k-textbox" name="start" data-bind="value: StartViewTime">
                                                </td>
                                                <td align="right">
                                                    <label for="ReservedTime">Time:</label>
                                                </td>
                                                <td>
                                                    <input type="text" id="reservedTimeTextbox" class="k-input k-textbox" name="reservedTime" data-bind="value: ReservationViewTime" style="border-width: 0px;" disabled="disabled">
                                                </td>
                                            </tr>
 
                                            <tr>
                                                <td align="right">
                                                    <label for="Duration">Duration:</label>
                                                </td>
                                                <td>
                                                    <select name="duration" id="durationDropDownList" data-bind="value: Duration">
                                                        @foreach (var dur in (List<ServicePROWeb.ServiceProWCFService.TypeMstr>)HttpContext.Current.Session["DurationList"])
                                                        {
                                                            <option value='@dur.ty_code_desc'>@dur.ty_code_desc</option>
                                                        }
                                                    </select>
                                                </td>
                                                <td align="right">
                                                    <label for="ReservationID">Reservation ID:</label>
                                                </td>
                                                <td>
                                                    <input type="text" id="reservationIDTextbox" class="k-input k-textbox" name="reservationID" data-bind="value: ReservationID" style="border-width: 0px;width:100%" disabled="disabled">
                                                </td>
                                            </tr>
 
                                            <tr>
                                                <td align="right">
                                                    <label for="TechName">Tech:</label>
                                                </td>
                                                <td colspan="3">
                                                    <input type="text" class="k-input k-textbox" name="techName" data-bind="value: TechName" disabled="disabled">
                                                </td>
                                            </tr>
 
                                            <tr>
                                                <td align="right">
                                                    <label for="Title">Reason for Reservation:</label>
                                                </td>
                                                <td colspan="3">
                                                    <input type="text" class="k-input k-textbox" name="title" data-bind="value: title" style="width: 60%;">
                                                </td>
                                            </tr>
 
                                            <tr>
                                                <td>
                                                     
                                                </td>
                                                <td colspan="3">
                                                    <input type="checkbox" id="chkRecurring">Recurring Reservation
                                                </td>
                                            </tr>
                                        </table>
                                        <br />
                                        <div id="divRecurring" style="width: 95%; margin-left: 5px; padding: 10px;">
                                            <input type="radio" name="rdoTech" value="c" checked="checked">Current Tech
                                            <input type="radio" name="rdoTech" value="a" style="margin-left: 15px;">All Techs
                                            <span style="margin-left: 24px;">Every: </span><input type="text" id="everyTextbox" class="k-input k-textbox" name="recurrenceNumber" data-bind="value: RecurrenceNumber">
                                            <input type="radio" name="rdoRecurrenceFrequency" value="d" checked="checked" style="margin-left: 15px;">Day(s)
                                            <input type="radio" name="rdoRecurrenceFrequency" value="w" style="margin-left: 15px;">Weeks(s)
                                            <input type="radio" name="rdoRecurrenceFrequency" value="m" style="margin-left: 15px;">Month(s)
                                            <br /><br />
                                            <input type="checkbox" id="chkIncludeBusinessDays">Include Non-Business Days
                                            <span style="margin-left: 30px;">Until: </span><input type="text" id="untilDateTextbox" class="k-input k-textbox" name="until">
                                            <span style="margin-left: 15px;">(max. 3 months)</span>
                                        </div>
                                    </div>
                                </script>
 

$('#chkRecurring').click(function () {
    $("#divRecurring1").hide();
});
 

Thanks

Kevork
Top achievements
Rank 2
 answered on 22 Oct 2015
2 answers
518 views

I am having a play around with the grid.  I have implemented the following example where batch update/create/delete from this post kendo-grid-batch-incell-save-changes-with-single-trigger-for-create-update-destroy.  This works nicely where I get the rows being created/updated/deleted.

However, if I need to do some custom server side validation in a save event before the changes are committed - if there are any errors, is it possible to return the errors and set them back in the grid supposing my save send handler is:

function sendSaveAllData() {
            var grid = $('#mygrid').data("kendoGrid");
            var finalData = ...;
 
            // send the data with one request to the server
            $.ajax({
                url: "@Url.Action("SaveAllBatchChanges", "MyController")",
                data: finalData,
                type: "POST",
                error: function () {
                    //Handle the server errors
                },
                success: function (data) {
                    //alert("update on server is completed");
 
                    showMessage('success', 'My Batch', 'Successfully saved batch changes.')
 
                    //refresh the grid
                    grid.dataSource._destroyed = [];
                    grid.dataSource.read();
                }
            })
        }

With controller method:

public ActionResult SaveAllBatchChanges(
            [Bind(Prefix = "updated")]List<BatchEditModel> updated,
            [Bind(Prefix = "new")]List<BatchEditModel> created,
            [Bind(Prefix = "deleted")]List<BatchEditModel> destroyed)
        {
 
            // do some validation before notifying server
            // save if valid
 
            return Json("Success!");
        }

At the minute I show a popup message to the user which reads success - but I haven't got any code in place currently to do the validate until I find something concrete to put in place.

Ideally I want to set cell style of errors in the grid if possible back in the browser - ie red background colour if the cell contains an error. 

Is there a way to manually set error messages in the grid (client side) and highlight the error cells from an external ajax post?

Thanks

Andez

 

Paul
Top achievements
Rank 1
 answered on 21 Oct 2015
1 answer
149 views

Hello,

 I need to format some cell in export excell with kendo mvc grid. I use the export in this way :

.Index.cshtml :

 .ToolBar(tools => tools.Excel())
.Excel(excel => excel
.FileName("Export.xlsx")
.ForceProxy(true)
.Filterable(true)
.AllPages(true)
.ProxyURL(Url.Action("ExcelSave", "CieAssistant"))
)

 Controller :

public ActionResult ExcelSave(string contentType, string base64, string fileName)
{
var fileContents = Convert.FromBase64String(base64);
return File(fileContents, contentType, fileName);
}

 

How i can update format of cell in the controller function "ExcelSave" ?!

 

Thanks,

Patrick | Technical Support Engineer, Senior
Telerik team
 answered on 21 Oct 2015
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
Upload
ComboBox
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
ListView (Mobile)
Pager
Accessibility
ColorPicker
DateRangePicker
Wizard
Security
Styling
Chat
MediaPlayer
TileLayout
DateInput
Drawer
SplitView
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Template
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Rating
ScrollView
ButtonGroup
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
DateTimePicker
AppBar
BottomNavigation
Card
FloatingActionButton
Licensing
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
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?