Telerik Forums
UI for ASP.NET MVC Forum
2 answers
361 views
Hi,

I tested a web application with kendo (the last version 2014.1.318), this app works fine in Chrome but in Firefox the behaviour is strange, for example the dropdownlist works fine until I search and the data shown in the kendo grid, after the search the dropdownlist doesn't show the items or show and hide they very fast.

I put an example of how scripts I import and how I used them.

<link rel="stylesheet" href="@Url.Content("~/Content/kendo/2014.1.318/kendo.common.min.css")"type="text/css" />
    <link rel="stylesheet" href="@Url.Content("~/Content/kendo/2014.1.318/kendo.default.min.css")"type="text/css" />
    <script src="@Url.Content("~/Scripts/kendo/2014.1.318/jquery.min.js")"type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/kendo/2014.1.318/kendo.all.min.js")"type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/kendo/2014.1.318/kendo.aspnetmvc.min.js")"type="text/javascript"></script>
 
@{
    ViewBag.Title = "Control Interno";
    Layout = "~/Views/Home/PaginaInicio.cshtml";
}
 
<h2 class="Cabecera">Control interno</h2>
 
<div>
   <table style="font-size: x-small" align="center">
            <tr>
                <td>
                    <label for="start">Desde: </label><label class="obligatorio">*</label>
                    @(Html.Kendo().DatePicker().Name("txtFechaInicio").Events(e => e.Change("startChange")).Value(ViewBag.Fecha))
                </td>
                <td>
                    <label for="end" style="margin-left:3em">Hasta: </label><label class="obligatorio">*</label>
                    @(Html.Kendo().DatePicker().Name("txtFechaFin").Events(e => e.Change("endChange")).Value(ViewBag.Fecha))
                </td>
            </tr>
    </table>
    
    <br />
 
    <table style="font-size: x-small" align="center">
            <tr>
                <td>
                   <label>Tipo de control</label>
                    @(Html.Kendo().DropDownList()
                      .Name("tipocontrol")
                      .OptionLabel("Todos")
                      .DataTextField("NOMBRE_TIPOCONTROL")
                      .DataValueField("ID")
                      .AutoBind(false)
                      .DataSource(source =>
                      {
                          source.Read(read =>
                          {
                              read.Action("ToolbarTemplate_TipoControl", "Consultas");
                          });
                      })
                    )
                </td>
 
                <td>
                   <label> Mostrar registros: </label>
                   @(Html.Kendo().DropDownList()
                      .Name("tipocaso")
                      .OptionLabel("Todos")
                      .DataTextField("NOMBRE_TIPOCASO")
                      .DataValueField("ID")
                      .AutoBind(false)
                      .DataSource(source =>
                      {
                          source.Read(read =>
                          {
                              read.Action("ToolbarTemplate_TipoCaso", "Consultas");
                          });
                      })
                    )
                </td>
            </tr>
            
    </table>
 
    <br />
    <p>
        <label class="obligatorio">(*) Campo obligatorio</label>
    </p>
 
    <br />
 
    <table style="font-size: x-small" align="center">
        <tr>
            <td>
                @*<input type="Button" value="Buscar" onclick="BindGrid();" class="BotonBuscar" />*@
                <button type="button" id="btnSearch" onclick="BindGrid();" value="Buscar" class="k-button" >
                <img src="../../Images/Buscarboton.png" />
                </button>
            </td>
        </tr>
    </table>
     
</div>
<br />
  
<div>
    <table style="font-size: x-small" align="center" id="tabDato">
        <tr>
            <td class="etiquetas1" align="right">
                <label><strong>Desde: </strong></label>
            </td>
            <td class="etiquetas2">
                <label id="lblDesde"></label>
            </td>
            <td class="etiquetas1" align="right">
                <label><strong>Hasta: </strong></label>
            </td>
            <td class="etiquetas2">
                <label id="lblHasta"></label>
            </td>
        </tr>
        <tr>
            <td class="etiquetas1" align="right">
                <label><strong>Tipo de control: </strong></label>
            </td>
            <td class="etiquetas2">
                <label id="lblControl"></label>
            </td>
            <td class="etiquetas1" align="right">
                <label><strong>Mostrar registros: </strong></label>
            </td>
            <td class="etiquetas2">
                <label id="lblCaso"></label>
            </td>
        </tr>
    </table>
</div>
 
<br />
 @model IEnumerable< SIS_CSC.ViewMoldels.ControlInternoViewData>
<div style="font-size:xx-small">
    @(Html.Kendo().Grid(Model)
        .Name("Grid")
        .Columns(columns =>
                {
                    columns.Template(t => { }).Title("N°").ClientTemplate("#= renderRecordNumber(data) #").Width(40);
                    columns.Bound(p => p.ID_SOLICITUDSERVICIO).Visible(false);
                    columns.Bound(p => p.NOMBRE_CLIENTE).Title("Cliente");
                    columns.Bound(p => p.SFECHA_SOLICITOSERVICIO).Title("Fecha");
                    columns.Command(command => command.Custom("custom").Text("").Click("MostrarSolicitud")).Title("N° de solicitud").Width(75);
                    columns.Bound(p => p.SERIE_EQUIPO).Title("N° de serie");
                    columns.Bound(p => p.NOMBRE_TECNICO).Title("Técnico");
                    columns.Bound(p => p.NOMBRE_UNIDADNEGOCIO).Title("Siglas");
                    columns.Bound(p => p.SUGERENCIA_TECNICO).Title("Sugerencia del técnico");
                    columns.Bound(p => p.OBSERVACION_CLIENTE).Title("Observación del cliente");
                    columns.Bound(p => p.SUGERENCIA_INTERNA).Title("Sugerencia interna");
                    columns.Bound(p => p.CASO_CERRADO).Visible(false);
                    columns.Command(command => command.Custom("Gestionar").Text("").Click("GestionarCI")).Title("Gestionar").Width(75);
                })
                       .Filterable()
                       .Sortable()
                       .Pageable(m => m.PageSizes(new int[] { 10, 20, 50, 100 }))
                       .Groupable()
                       .Events(e => e.DataBound("dataBound"))
                       .Scrollable(s => s.Height("auto"))
                       .TableHtmlAttributes(new { style = "table-layout: fixed;" })
                       .Resizable(r => r.Columns(true))
               .DataSource(dataSource => dataSource
                   .Ajax()
                   .Events(ev =>
                    {
                        ev.RequestStart("Load");
                        ev.RequestEnd("Ready");
                    })
                   .Read(read => read.Action("LeerExt_ControlInterno", "Consultas").Data("getParameter"))
                   .Model(model => { model.Id(p => p.ID_SOLICITUDSERVICIO); })
               )
               .ToolBar(toolBar =>
                    toolBar.Custom()
                        .Text("Exportar a PDF")
                        .HtmlAttributes(new { id = "export" })
                        .Url(Url.Action("ExportarPDFControlInterno", "Consultas",
                        new
                        {
                            page = 1,
                            pageSize = "~",
                            filter = "~",
                            sort = "~",
                            txtFechaInicio = "~",
                            txtFechaFin = "~",
                            tipocontrol = "0",
                            tipocaso = "0",
                            nombre_control = "Todos",
                            nombre_caso = "Todos"
                        }))
                )
                .ToolBar(toolBar =>
                    toolBar.Custom()
                        .Text("Exportar a Excel")
                        .HtmlAttributes(new { id = "exportex" })
                        .Url(Url.Action("ExportarExcelControlInterno", "Consultas",
                        new
                        {
                            page = 1,
                            pageSize = "~",
                            filter = "~",
                            sort = "~",
                            txtFechaInicio = "~",
                            txtFechaFin = "~",
                            tipocontrol = "0",
                            tipocaso = "0",
                            nombre_control = "Todos",
                            nombre_caso = "Todos"
                        }))
 
                )
           )
</div>
 
<div>
    @(Html.Kendo().Window()
    .Name("Rates")
    .Title("Solicitud de servicio")
    .Visible(false)
    .Modal(true)
    .Draggable(true)
    .Width(800)
    .Height(600)
    .Events(e =>
    {
        e.Open("onOpen");
        e.Refresh("onRefresh");
    })
)
</div>
 
<div>
    @(Html.Kendo().Window()
    .Name("GCI")
    .Title("Gestionar control interno")
    .Visible(false)
    .Modal(true)
    .Draggable(true)
    .Width(600)
    .Height(400)
    .Events(e =>
    {
        e.Open("onOpen");
        e.Refresh("onRefresh");
    })
)
</div>
 
<div>
    @(Html.Kendo().Window()
    .Name("CCI")
    .Title("Control interno")
    .Visible(false)
    .Modal(true)
    .Draggable(true)
    .Width(600)
    .Height(400)
    .Events(e =>
    {
        e.Open("onOpen");
        e.Refresh("onRefresh");
    })
)
</div>
 
<script type="text/javascript">
    function Load(e) {
        kendo.ui.progress($("#Grid"), true);
    }
 
    function Ready(e) {
        kendo.ui.progress($("#Grid"), false);
    }
 
    function onOpen(e) {
        kendo.ui.progress(e.sender.element, true);
    }
 
    function onRefresh(e) {
        kendo.ui.progress(e.sender.element, false);
    }
</script>
 
<script type="text/javascript">
    var rowNumber = 1;
    var flag = false;
 
    function resetRowNumber(e) {
        rowNumber = 1;
    }
 
    function renderRecordNumber(data) {
        var page = parseInt($("#Grid").data("kendoGrid").dataSource.page()) - 1;
        var pagesize = $("#Grid").data("kendoGrid").dataSource.pageSize();
        return parseInt(rowNumber++ + (parseInt(page) * parseInt(pagesize)));
    }
 
</script>
 
<script type="text/javascript">
 
    $(document).ready(function () {
        OcultarControl("tabDato", true);
    });
 
    function CambiarTexto() {
 
        var desde = $("#txtFechaInicio").val();
        var hasta = $("#txtFechaFin").val();
        var tipocontrol = $("#tipocontrol").data("kendoDropDownList").text();
        var tipocaso = $("#tipocaso").data("kendoDropDownList").text();
 
        $("#lblDesde").text(desde);
        $("#lblHasta").text(hasta);
        $("#lblControl").text(tipocontrol);
        $("#lblCaso").text(tipocaso);
 
        OcultarControl("tabDato", false);
    }
 
</script>
 
<script type="text/javascript">
    function dataBound(e) {
 
        //var pageSizes = [{ text: "10", value: 10 }, { text: "20", value: 20 }, { text: "50", value: 50 },
        //    { text: "100", value: 100 }, { text: "Todo", value: 1000000 }];
 
        //$('.k-pager-sizes select[data-role="dropdownlist"]').data('kendoDropDownList')
        //    .setDataSource(new kendo.data.DataSource({ data: pageSizes }));
 
        resetRowNumber(e);
 
        var rows = this.table.find("tr[role='row']");
        for (var i = 0; i < rows.length; i++) {
            var model = this.dataItem(rows[i]);
            $(rows[i]).find(".k-grid-custom").contents().last()[0].textContent = model.CODIGO_SOLICITUDSERVICIO;
 
            if (model.CASO_CERRADO == false || model.CASO_CERRADO == null) {
                $(rows[i]).find(".k-grid-Gestionar").contents().last()[0].textContent = "Gestionar";
            }
            else {
                $(rows[i]).find(".k-grid-Gestionar").contents().last()[0].textContent = "Cerrado";
            }
        }
 
        var grid = $('#Grid').data('kendoGrid');
 
        var requestObject = (new kendo.data.transports["aspnetmvc-server"]({ prefix: "" }))
        .options.parameterMap({
            page: grid.dataSource.page(),
            sort: grid.dataSource.sort(),
            filter: grid.dataSource.filter(),
            txtFechaInicio: $("#txtFechaInicio").val(),
            txtFechaFin: $("#txtFechaFin").val(),
            tipocontrol: $("#tipocontrol").val(),
            tipocaso: $("#tipocaso").val(),
            nombre_control: $("#tipocontrol").data("kendoDropDownList").text(),
            nombre_caso: $("#tipocaso").data("kendoDropDownList").text()
        });
 
        // EXPORTAR A PDF
        var $exportLink = $('#export');
        var href = $exportLink.attr('href');
        href = href.replace(/page=([^&]*)/, 'page=' + requestObject.page || '~');
        href = href.replace(/sort=([^&]*)/, 'sort=' + requestObject.sort || '~');
        href = href.replace(/pageSize=([^&]*)/, 'pageSize=' + grid.dataSource.total());
        href = href.replace(/filter=([^&]*)/, 'filter=' + (requestObject.filter || '~'));
        href = href.replace(/txtFechaInicio=([^&]*)/, 'txtFechaInicio=' + (requestObject.txtFechaInicio || ""));
        href = href.replace(/txtFechaFin=([^&]*)/, 'txtFechaFin=' + (requestObject.txtFechaFin || ""));
        href = href.replace(/tipocontrol=([^&]*)/, 'tipocontrol=' + (requestObject.tipocontrol || ""));
        href = href.replace(/tipocaso=([^&]*)/, 'tipocaso=' + (requestObject.tipocaso || ""));
        href = href.replace(/nombre_control=([^&]*)/, 'nombre_control=' + (requestObject.nombre_control || ""));
        href = href.replace(/nombre_caso=([^&]*)/, 'nombre_caso=' + (requestObject.nombre_caso || ""));
        $exportLink.attr('href', href);
 
 
        // EXPORTAR A EXCEL
        var $exportLinkex = $('#exportex');
        var hrefex = $exportLinkex.attr('href');
        hrefex = hrefex.replace(/page=([^&]*)/, 'page=' + requestObject.page || '~');
        hrefex = hrefex.replace(/sort=([^&]*)/, 'sort=' + requestObject.sort || '~');
        hrefex = hrefex.replace(/pageSize=([^&]*)/, 'pageSize=' + grid.dataSource.total());
        hrefex = hrefex.replace(/filter=([^&]*)/, 'filter=' + (requestObject.filter || '~'));
        hrefex = hrefex.replace(/txtFechaInicio=([^&]*)/, 'txtFechaInicio=' + (requestObject.txtFechaInicio || ""));
        hrefex = hrefex.replace(/txtFechaFin=([^&]*)/, 'txtFechaFin=' + (requestObject.txtFechaFin || ""));
        hrefex = hrefex.replace(/tipocontrol=([^&]*)/, 'tipocontrol=' + (requestObject.tipocontrol || ""));
        hrefex = hrefex.replace(/tipocaso=([^&]*)/, 'tipocaso=' + (requestObject.tipocaso || ""));
        hrefex = hrefex.replace(/nombre_control=([^&]*)/, 'nombre_control=' + (requestObject.nombre_control || ""));
        hrefex = hrefex.replace(/nombre_caso=([^&]*)/, 'nombre_caso=' + (requestObject.nombre_caso || ""));
        $exportLinkex.attr('href', hrefex);
    }
 
    function MostrarSolicitud(e) {
        e.preventDefault();
        var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
        var direction = "/Consultas/SomeAction/" + dataItem.ID_SOLICITUDSERVICIO;
        var wnd = $("#Rates").data("kendoWindow");
        if (!wnd) {
            // first click of the button - will automatically fetch the contentUrl
            wnd = $("#Rates").kendoWindow({
                title: "Solicitud de servicio",
                actions: ["Close"],
                content: direction,
                visible: false,
                modal: true
            }).data("kendoWindow");
        }
        wnd.refresh(direction);
        wnd.center();
        wnd.open();
    }
 
    function GestionarCI(e) {
        e.preventDefault();
        var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
        var direction = "/Consultas/GestionarControlInterno/" + dataItem.ID_SOLICITUDSERVICIO;
         
        if (dataItem.CASO_CERRADO == false || dataItem.CASO_CERRADO == null) {
            var wnd = $("#GCI").data("kendoWindow");
            if (!wnd) {
                // first click of the button - will automatically fetch the contentUrl
                wnd = $("#GCI").kendoWindow({
                    title: "Gestionar control interno",
                    actions: ["Close"],
                    content: direction,
                    visible: false,
                    modal: true
                }).data("kendoWindow");
            }
 
        }
        else {
            var wnd = $("#CCI").data("kendoWindow");
            if (!wnd) {
 
                // first click of the button - will automatically fetch the contentUrl
                wnd = $("#CCI").kendoWindow({
                    title: "Control interno",
                    actions: ["Close"],
                    content: direction,
                    visible: false,
                    modal: true
                }).data("kendoWindow");
            }
            //            wnd1.refresh(direction);
            //            wnd1.center();
            //            wnd1.open();
        }
        wnd.refresh(direction);
        wnd.center();
        wnd.open();
         
    }
 
</script>
 
 
<script type="text/javascript">
    function getParameter() {
        return {
            txtFechaInicio: $("#txtFechaInicio").val(),
            txtFechaFin: $("#txtFechaFin").val(),
            tipocontrol: $("#tipocontrol").val(),
            tipocaso: $("#tipocaso").val(),
            bandera: flag
        };
    }
 
    function BindGrid() {
        flag = true;
        CambiarTexto();
        $("#Grid").data("kendoGrid").dataSource.read();
        $("#Grid").data("kendoGrid").refresh();
    }
</script>
 
<script type="text/javascript">
        function startChange() {
            var endPicker = $("#txtFechaFin").data("kendoDatePicker"),
            startDate = this.value();
 
            if (startDate) {
                startDate = new Date(startDate);
                startDate.setDate(startDate.getDate());
                endPicker.min(startDate);
            }
        }
 
        function endChange() {
            var startPicker = $("#txtFechaInicio").data("kendoDatePicker"),
            endDate = this.value();
 
            if (endDate) {
                endDate = new Date(endDate);
                endDate.setDate(endDate.getDate());
                startPicker.max(endDate);
            }
        }
 
</script>

Thanks for the help.

Regards
Misahael
Top achievements
Rank 1
 answered on 09 Apr 2014
2 answers
450 views

[HttpPost]
public ActionResult Submit(HttpPostedFileBase files,)
{
if (files != null && files.ContentLength > 0)
{
var filename = Path.GetFileName(files.FileName);
MemoryStream target = new MemoryStream();
files.InputStream.CopyTo(target);
byte[] data = target.ToArray();

//"Reconcile" is from DropDown1(Cabinate) and  "Microsoft" is DropDown2(Publisher)

CheckInDoc( "Reconcile", "Microsoft", filename , data);
 
}
return RedirectToAction("Result");
}





<form method="post" action='@Url.Action("Submit")' style="width:45%">
<h3>Cabinate</h3>
@(Html.Kendo().DropDownList()
.Name("Cabinate")
.DataTextField("Text")
.DataValueField("Value")
.Events(e => e.Change("change"))
.BindTo(new List<SelectListItem>() {
new SelectListItem() {
Text = "Selet Cabinate",
Value = "-1"
},
new SelectListItem() {
Text = "Reconcile",
Value = "1"
},
new SelectListItem() {
Text = "Discovery",
Value = "2"
}
})
.Value("-1")
)
<h3>Folder</h3>
@(Html.Kendo().DropDownList()
.Name("Folder")
.BindTo(new List<string>() { "Select Publisher", "Microsoft", "Telerik", "Redhate" })
)
 
<div class="demo-section">
@(Html.Kendo().Upload()
.Name("files")
)
<p>
<input type="submit" value="Submit" class="k-button" />
</p>
</div>
</form>
Georgi Krustev
Telerik team
 answered on 09 Apr 2014
2 answers
1.9K+ views
I have a three level grid from which users may navigate to views and return to the grid.  I want to put them back in the context they left.  I'm really having trouble figuring out how to do this.  I've been able to save the data-uid of an expanded row at the top level, but I can't seem to find it when the page loads after the user returns.  Maybe I'm not subscribing to the correct event?

I've subscribed to 

.Events(events => events.DataBound("onDataBound").DetailInit("onDetailInit").DetailExpand("onExpand").DetailCollapse("onCollapse"))

In onExpand I have

function onExpand(e) {
    //alert('onExpand was called. BatchID = ' + e.masterRow.closest("tr.k-master-row").attr('data-uid'));
    // save the data-uid value in the session
    var selectedBatchID = e.masterRow.closest("tr.k-master-row").attr('data-uid')
    $.post('@Url.Action("SetSessionVariable", "Home")',
        {
            key: 'lastSelectedBatchID',
            value: selectedBatchID
        });
}
 
I think I want to get the row in onDataBound or possibly onDataBinding but can't get a handle on the desired row.  I've looked a lots of examples that are ll different and none of them work for me.

Once I get the top level row expanded, then I'll need to do the same for the second and third levels.  Can you give an example of how this is done?  All the demos I've see so far are super simple and really don't seem to apply or don't give context as to which event is being subscribed to.

Thanks!

Rich


Richard
Top achievements
Rank 1
 answered on 09 Apr 2014
3 answers
585 views
I have model class like so:
public class ServerModel
{
    public Guid Id { get; set; }
    public CustomerModel Customer { get; set; }
    public string Name { get; set; }
}

Inside a Kendo Grid, I'd like to display a link to the Customer, but as the Customer can be null, I'm having trouble getting this link to only show when the customer is not null. Below is the client template I'm trying to use:
@(Html.Kendo().Grid(Model)
      .Name("Grid")
      .Columns(columns =>
      {
          columns.Bound(s => s.Name)
                 .ClientTemplate("<a href='" + Url.Action("Details", "Server") + "/#= ID #'>#= Name #</a>");
          columns.Bound(s => s.Hostname);
          columns.Bound(s => s.Customer.Name).Title("Customer")
                 .ClientTemplate("#= Customer ? '<a href=\'" + Url.Action("Details", "Customer") + "/#= ID #\'>#= Customer.Name #</a>' : 'Unknown'#");
          columns.Bound(s => s.Reported).Title("Last Reported (UTC)").Format("{0:yyyy-MM-dd hh:mm:ss tt}");
      })

This just gives me a template error, though.
Dimiter Madjarov
Telerik team
 answered on 08 Apr 2014
4 answers
1.3K+ views
I have a kendo ui grid with a custom editor template. I want to be able to hide the editor for 2 fields on the popup editor based on the value of a 3rd field.

eg on the kendo grid if property a is set to true, then when the user selects edit and the popup shows,  property b and c editors are not displayed. However if property a is false then editors(textboxes) for b and c must be shown on the popup.

I have tried to do the following:

                    @(Html.Kendo().Grid(Model)
                    .Name("Grid")
                    .Events(e=>e.
                            Edit("Grid_Edit")
                             )
                    .Columns(columns => 


then 
<script>
    function Grid_Edit(e) {
        var dataItem = e.dataItem;
        var mode = e.mode;
        var form = e.form;
if (dataItem.UseIntegratedSecurity)
         $(form).find("#Username").hide()

    }
</script>

to try and debug i have done the following:
<script>
    function Grid_Edit(e) {
        var dataItem = e.dataItem;
        var mode = e.mode;
        var form = e.form;
        if (dataItem.IntegratedSecurity==true)
            alert("integrated security")
        
    }
</script>
 But the alert is never displayed even when this field is set to true.

Am I on the right track or is there an easier way to achieve my goal?

Daniel
Telerik team
 answered on 08 Apr 2014
1 answer
229 views
Hi,

I am populating a Stacked Column Chart with a date axis. However, I only want to display monday-friday so I only populate the chart with dates from my data set that are weekdays.

The chart is automatically adding blank spaces for the missing dates (weekends). When I changed it to a category axis it stopped stacking my bars and completely distorted the graph... as it created a new column for every single data point. Is there a way to hide the dates without data? Do I need to change my implementation in order to change the axis from date to category or a stacked bar chart?

relevant code:
public class DataViewModel
    {
        public string Category { get; set; }
        public double? Phone { get; set; }
        public double? ClaimsWork { get; set; }
        public double? Unstaffed { get; set; }
        public double? Outbound { get; set; }
        public double? Meetings { get; set; }
        public double? Personal { get; set; }
        public DateTime Date { get; set; }
 }

          .Series(series =>
          {
              {
                  series.Column(model => model.Phone).Name("Phone").Stack(ChartStackType.Stack100).Color("#009bd7");
                  series.Column(model => model.ClaimsWork).Name("ClaimsWork").Stack(ChartStackType.Stack100).Color("#76b800");
                  series.Column(model => model.Unstaffed).Name("Unstaffed").Stack(ChartStackType.Stack100).Color("#d43851");
                  series.Column(model => model.Outbound).Name("Outbound").Stack(ChartStackType.Stack100).Color("#ffd600");
                  series.Column(model => model.Meetings).Name("Meetings").Stack(ChartStackType.Stack100).Color("#AF81C9");
                  series.Column(model => model.Personal).Name("Personal").Stack(ChartStackType.Stack100).Color("#ef4c00");
              }

          })
          .CategoryAxis(axis => axis
              .Labels(label => label
                  .Step(2)
              )
              .Name("label-axis")
              .Categories(model => model.Date)
          ) 





Iliana Dyankova
Telerik team
 answered on 08 Apr 2014
4 answers
124 views
Hi all,
I need help with the "Create" operation.
When I create a new task, the Scheduler doesn't send any data to the Controller method.

My C# object is:

public class Reservation : ISchedulerEvent
    {
        public virtual int IdReservation { get; set; }
        public virtual int? IdWorker { get; set; }
        public virtual int IdRoom { get; set; }
        public virtual string Title { get; set; }
        public virtual string Description { get; set; }
        public virtual DateTime Start { get; set; }
        public virtual string StartTimezone { get; set; }
        public virtual DateTime End { get; set; }
        public virtual string EndTimezone { get; set; }
        public virtual string RecurrenceRule { get; set; }
        public virtual string RecurrenceException { get; set; }
        public virtual bool IsAllDay { get; set; }
        public virtual DateTime ReservationDate { get; set; }
    }

and the Javascript is:

$("#scheduler").kendoScheduler({
        date: new Date("2014/3/25"),
        startTime: new Date("2014/3/25 07:00 AM"),
        height: 600,
        views: [
            "day",
            { type: "workWeek", selected: true },
            "week",
            "month",
            "agenda"
        ],
        timezone: "Etc/UTC",
        dataSource: {
            batch: true,
            transport: {
                read: {
                    url: "/Reservation/Read",
                    dataType: "json",
                    type: "POST"
                },
                update: {
                    url: "/Reservation/Update",
                    dataType: "json",
                    type: "POST"
                },
                create: {
                    url: "/Reservation/Create",
                    dataType: "json",
                    type: "POST"
                },
                destroy: {
                    url: "/Reservation/Delete",
                    dataType: "json",
                    type: "POST"
                },
                parameterMap: function (options, operation) {
                    if (operation !== "read" && options.models) {
                        return { models: kendo.stringify(options.models) };
                    }
                }
            },
            schema: {
                model: {
                    id: "idReservation",
                    fields: {
                        idReservation: { from: "IdReservation", type: "number", defaultValue: 1 },
                        worker: { from: "IdWorker", type: "number", defaultValue: 1 },
                        roomId: { from: "IdRoom", type: "number" },
                        title: { from: "Title", defaultValue: "No title" },
                        description: { from: "Description", defaultValue: "" },
                        start: { from: "Start", type: "date" },
                        startTimezone: { from: "StartTimezone", defaultValue: null },
                        end: { from: "End", type: "date" },
                        endTimezone: { from: "EndTimezone", defaultValue: null },
                        recurrenceRule: { from: "RecurrenceRule" , defaultValue: null },
                        recurrenceException: { from: "RecurrenceException", defaultValue: null },
                        isAllDay: { from: "IsAllDay", type: "boolean", defaultValue: false },
                        reservationDate: { from: "ReservationDate", type: "date", defaultValue: new Date() }
                    }
                }
            }
        }
    });

and, this is my "Create" (MVC Controller) method is:

public virtual JsonResult Create([DataSourceRequest] DataSourceRequest request, Reservation reservation)
{
    ...
}

Please, can anyone help me to know why the properties in the "reservation" parameter ("Create" method) are all empties?

Thanks
Mattia
Top achievements
Rank 1
 answered on 08 Apr 2014
2 answers
108 views
trying to initialize my Kendo ui grid. I am able to populate it using the View object, but when I try doing it in Json format (i.e. when moving to next page) I get a screen showing json results instead of my view.Here's the controller code: public class CampaignsController : Controller
{
//
// GET: /Campaigns/


[HttpGet]
public ActionResult Index()
{
return View(GetAllCampaigns());
}


public ActionResult Campaigns_Read([DataSourceRequest] DataSourceRequest request)
{
DataSourceResult result = GetAllCampaigns().ToDataSourceResult(request);
return Json(result, JsonRequestBehavior.AllowGet);
}


private static IEnumerable<NH_Campaign> GetAllCampaigns()
{
List<NH_Campaign> result = null;
if (MBPDataAccess.Instance.GetAll(out result))
{
return result;
}
return new List<NH_Campaign>();
}and the cshtml is :@model IEnumerable<MBP.NH_Campaign>

<h2>View1</h2>


@(Html.Kendo().Grid(Model)
.Name("CGrid")
.Columns(columns =>
{
columns.Bound(p => p.CampaignID).Title("Id");
columns.Bound(p => p.CampaignName).Title("Name");
columns.Bound(p => p.ClickUrlC2C_OFF).Title("Click URL");
columns.Bound(p => p.PlatformID).Title("Platform ID");
})
//.Groupable()
.Pageable()
//.Sortable()
//.Filterable()
.DataSource(dataSource => dataSource.Ajax().PageSize(2).Read(read => read.Action("Campaigns_Read", "Campaigns"))
));the Index action that is called when the page is loaded works great, but when I try to move to the next page the Camapigns_Read action is called but I get a blank page with json results.
 i want to perform paging on server-side
What am I missing here? 
Richard
Top achievements
Rank 1
 answered on 08 Apr 2014
1 answer
85 views
Hi,
I am quite new to telerik and having some problem with datetime picker.
@Html.Kendo().DatePicker().Name("dtpicker")) is the code i am using. It does not show any error but only shows textbox instead of showing datetime picker control.

Thanks.
Atanas Korchev
Telerik team
 answered on 07 Apr 2014
4 answers
278 views

I am working an application using Kendo Grid on an MVC application.  Starting at about 10:30 (central time) yesterday, the kendo grid software stopped working.  I am using IE 10 on a Windows 7 OS. The error is

Unhandled exception at line 3, column 23238 in http://cdn.kendostatic.com/2014.1.318/js/jquery.min.js
0x80020003 - JavaScript runtime error: Member not found.

I am able to replicate the error in a simple application.  The View file contains the following definition for the grid

 

@(Html.Kendo().Grid<MvcApplication1.Models.TestItem>()
  .Name( "testItemGrid" )
  .Columns( columns =>
  {
    columns.Command( command =>
    {
      command.Edit();
    } ).Width( 195 );
    columns.Bound( x => x.ItemId );
    columns.Bound( x => x.Name );
  } )
  .ToolBar( toolbar =>
  {
    toolbar.Create().Text( "Add New Item" );
  } )
  .Sortable()
  .Editable( editable => editable.Mode( GridEditMode.InLine ) )
  .DataSource( ds => ds
    .Ajax()
    .Model( m =>
            {
              m.Id( x => x.ItemId );
            } )
     .Read( "TestItemRead", "TestItemGrid" )
     .Create( "TestItemCreate", "TestItemGrid" )
     .Update( "TestItemUpdate", "TestItemGrid" )
    )
  )

 

The controller contains the following actions:
 

public class TestItemGridController : Controller
{
  public ActionResult Index()
  {
    return View();
  }
 
  public ActionResult TestItemRead( [DataSourceRequest] DataSourceRequest request )
  {
    List<Models.TestItem> items = new List<Models.TestItem>();
    items.Add( new Models.TestItem() { ItemId = 1, Name = "Item 1" } );
    items.Add( new Models.TestItem() { ItemId = 2, Name = "Item 2" } );
    items.Add( new Models.TestItem() { ItemId = 3, Name = "Item 3" } );
    items.Add( new Models.TestItem() { ItemId = 4, Name = "Item 4" } );
    items.Add( new Models.TestItem() { ItemId = 5, Name = "Item 5" } );
    return Json( items.ToDataSourceResult( request ) );
  }
 
  public ActionResult TestItemCreate( [DataSourceRequest] DataSourceRequest request, Models.TestItem testItem )
  {
    if( testItem != null && ModelState.IsValid )
    {
    }
    return Json( new[] { testItem }.ToDataSourceResult( request, ModelState ) );
  }
 
  public ActionResult TestItemUpdate( [DataSourceRequest] DataSourceRequest request, Models.TestItem testItem )
  {
    if( testItem != null && ModelState.IsValid )
    {
    }
    return Json( ModelState.ToDataSourceResult() );
  }
}

 

I have tried several things to fix the error:
1. Update to latest version of Telerik software
 2. Use CDN support
 3. Use Local support

 I am at my wits end to resolve this issue.  Please help!

Leon
Top achievements
Rank 1
 answered on 07 Apr 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?