Telerik Forums
Kendo UI for jQuery Forum
1 answer
214 views
I have trouble getting the Kendo Grid ASP.NET MVC  Ajax implementation to work
The Javascript/Jquery version worked like a charm, the ASP.NET MVC has been quite a challenge.

I have a grid and a detail template. At first, when I added the ClientTemplate code, the page would display a javascript error of Invalid template. I searched for a while on this and 2 solutions were offered.
1. Commenting the System.WebSecurity.AntiXss enry form the Web.config
2. Using .ToMvcClientTemplate() as created by someone (Extension method on MvcHtmlString). The code for this is below

I tried both the options. now the page loads with no javascript error, but no mater how much i click on the arrow in the row (which should open the tab),
nothing happens. I even have  a break point in the controller that never gets hit.

One final note, when I change the mode to IE9, the page throws a javascript error:
Unhandled exception at line 18, column 19554 in http://localhost:1770/Scripts/kendo/2013.1.514/kendo.web.min.js

Please advise. Here is the code:

@(Html.Kendo().Grid<PPSPortal.Models.ATM>()
                                  .DataSource(dataSource => dataSource
                                      .Ajax()
                                      .Read(read => read.Action("GetATMStatusGrid", "ATM", new { id = participantId, userId = userId, pageid = 3 }))
                                      .PageSize(10)
                                      .ServerOperation(false)
                                   )
                                    .Events(ev => ev.DataBound("onDataBound"))
                                    .Name("Grid")
                                    .Sortable()
                                    .Filterable()
                                    .Pageable()
                                    .ColumnMenu().Events(x=>x.ColumnHide("UpdateColumnsWhenHidden").ColumnShow("UpdateColumnsWhenShown"))
                                    .Groupable()
                                    .ClientDetailTemplateId("template")
                                    .Columns(cl=>
                                        {
                                            cl.Bound(x => x.Id);
                                            cl.Bound(x => x.Name);
                                            cl.Bound(x => x.Status);
                                            cl.Bound(x => x.Active);
                                            cl.Bound(x => x.Online);
                                            cl.Bound(x => x.TotalCashRemaining).Format("{0:c}") ;
                                            cl.Bound(x => x.LastMessageFromATM);
                                            cl.Bound(x => x.LastMessageToATM);
                                            cl.Bound(x => x.GroupName);
                                            cl.Bound(x => x.Location);
                                        })
                                    .ToolBar(toolbar =>
                                    {
                                        toolbar.Template(@<text>
                                            <div class="toolbar">
                                                <table>
                                                    <tr>
                                                        <td>
                                                            @Html.JHAButton("Excel", "", "Export To Excel")
                                                            @Html.JHAButton("CSV", "", "Export To CSV")</td>
                                                    </tr>
                                                </table>
                                            </div>
                                            </text>);
                                    })
                )

@(Html.Kendo().TabStrip()
            .Name("tabStrip_#=Id#")
            .SelectedIndex(0)
            .Animation(animation => animation.Open(open => open.Fade(FadeDirection.In)))
            .Items(items =>
            {
                items.Add().Text("Events").Content(@<text>
                    @(Html.Kendo().Grid<PPSPortal.Models.ATMDetails>()
                        .Name("grid_#=Id#")
                        .Columns(columns =>
                        {
                            columns.Bound(o => o.Event).Width(56);
                            columns.Bound(o => o.MessageParamValue).Width(110);
                        })
                        .DataSource(dataSource => dataSource
                            .Ajax()
                            .PageSize(5)
                            .Read(read => read.Action("GetDetails", "ATM", new { id = @participantId, termId = "#=Id#", termName = "#=Name#" }))
                        )
                        .Pageable()
                        .Sortable()
                        .ToClientTemplate())
                </text>                        
                );
                items.Add().Text("Cassette Details").Content(
                "<div class='cassette-details'>" +
                "</div>"
                );                
            })
            .ToClientTemplate().ToMvcClientTemplate())


The MvcHtmlString extension method:

    public static class KendoMvcExtensions
    {
        public static IHtmlString ToMvcClientTemplate(this MvcHtmlString mvcString)
        {
            if (HttpEncoder.Current.GetType() == typeof(AntiXssEncoder))
            {
                var initial = mvcString.ToHtmlString();
                var corrected = initial.Replace("\\u0026", "&").Replace("%23", "#").Replace("%3D", "=").Replace("&#32;", " ");
                return new HtmlString(corrected);
            }

            return mvcString;
        }
    }

Another problem is that even though I have specified Groupable above, that does not work either. A circle with a line across it appears.
i suspect it could be the js files I am referencing.
They are bundled in the BundleConfig.cs.

This is the BundleConfig.cs


public class BundleConfig
    {
        // For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
        public static void RegisterBundles(BundleCollection bundles)
        {
            bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                        "~/Scripts/jquery-{version}.js"));

            bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
                        "~/Scripts/jquery-ui-{version}.js"));

            bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                        "~/Scripts/jquery.unobtrusive*",
                        "~/Scripts/jquery.validate*"));

            // Use the development version of Modernizr to develop with and learn from. Then, when you're
            // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
            bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                        "~/Scripts/modernizr-*"));


            bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
                        "~/Content/themes/base/jquery.ui.core.css",
                        "~/Content/themes/base/jquery.ui.resizable.css",
                        "~/Content/themes/base/jquery.ui.selectable.css",
                        "~/Content/themes/base/jquery.ui.accordion.css",
                        "~/Content/themes/base/jquery.ui.autocomplete.css",
                        "~/Content/themes/base/jquery.ui.button.css",
                        "~/Content/themes/base/jquery.ui.dialog.css",
                        "~/Content/themes/base/jquery.ui.slider.css",
                        "~/Content/themes/base/jquery.ui.tabs.css",
                        "~/Content/themes/base/jquery.ui.datepicker.css",
                        "~/Content/themes/base/jquery.ui.progressbar.css",
                        "~/Content/themes/base/jquery.ui.theme.css"));

            // Script bundles
            bundles.Add(new ScriptBundle("~/bundles/jhaCtls").Include(
                        "~/Telerik/js/jquery.min.js",
                        "~/Scripts/kendo/2013.1.514/kendo.web.min.js",
                        "~/Scripts/kendo/2013.1.514/kendo.all.min.js",
                        "~/Scripts/kendo/2013.1.514/kendo.aspnetmvc.min.js",
                        //"~/Scripts/kendo/2013.1.514/kendo.dataviz.min.js",
                        //"~/Scripts/kendo/2013.1.514/jquery.min.js",
                        "~/HTMLCtls/js/JHAHTMLCtls-2013.1.1.0.min.js"));

            // Style bundles
            bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css"));
            bundles.Add(new StyleBundle("~/Telerik/css").Include("~/Telerik/styles/kendo.common.min.css", "~/Telerik/styles/kendo.dataviz.min.css"));
        }
    }
Daniel
Telerik team
 answered on 25 Sep 2013
1 answer
147 views
Hi

I'm trying to use the kendo upload web control with C#, I can upload the controls is always on error, I know that I have to return an empty response but I don't know exactly how. This is my javascript

<script>
            $(document).ready(function () {
                $("#files").kendoUpload({
                    async: {
                        saveUrl: "Attachments.aspx",
                        removeUrl: "remove",
                        autoUpload: true
                    }
                });
            });
        </script>

and on C# I have

protected void Page_Load(object sender, EventArgs e)
    {
        HttpFileCollection x = Request.Files;

        if (x.Count>0)
        {
            Response.Clear();
            Response.ContentType = "application/json";
            Response.Write("{}"); 
        }
    }

I tried with Response.Write("") to with and without contentype but it didn't work.

Do anyone know how to build the correct success response?
Erick
Top achievements
Rank 1
 answered on 24 Sep 2013
2 answers
348 views

I have a ListView template that contains an index field (VentTypeId) and a text field (VentDescription) that shows text for the index field. The text field getter does a lookup up for the text corresponding to the index field.  I have an EditorTemplate with a dropdownlist to modify the index field, and after the save the index field is changed but the text field is not. I suppose I need to indicate that the text field has to be re-bound in the template after the edit, but don't know how.

Here is the relevant part of the View:

@(Html.Kendo().ListView<VentSetting>()
    .Name("VentSettings")
    .TagName("div")
    .ClientTemplateId("ventTemplate")
    .Editable()
    .DataSource(datasource => datasource
        .Model(model => model.Id(m => m.VentSettingId))
        .Read(read => read.Action("ReadVentSettings", "Run"))
        .Update(update => update.Action("UpdateVentSetting", "Run"))
    )
)

The relevant part of the template. Here the VentTypeId displays the changed value but the VentDescription field does not:

<script type="text/x-kendo-tmpl" id="ventTemplate">
    <div>
            <span>VentTypeId:</span><span>#:VentTypeId#</span>
            <span>Vent:</span><span>#:VentDescription# </span>
        </div>
    </div>
</script>

The relevant parts of the EditorTemplate

<div>
    @Html.Kendo().DropDownListFor(x => x.VentTypeId)
          .DataValueField("VentTypeId")
          .DataTextField("Description")
          .BindTo((System.Collections.IEnumerable)ViewData["VentTypes"])
 
    <div class="edit-buttons">
        <a class="k-button k-button-icontext k-update-button" href="\\#"><span class="k-icon k-update"></span>Save</a>
        <a class="k-button k-button-icontext k-cancel-button" href="\\#"><span class="k-icon k-cancel"></span>Cancel</a>
    </div>
 
</div>

The relevant parts of the VentSetting model:

public class VentSetting
{
        public int VentTypeId { get; set; }
 
        public string VentDescription
        {
            get
            {
                return VentTypeId == null ? "" : GetVentTypes().Single(v => v.VentTypeId == VentTypeId).Description;
            }
        }
    }

Any help would be appreciated.

Steve

Steve
Top achievements
Rank 1
 answered on 24 Sep 2013
4 answers
2.2K+ views
So I have a combobox that I have given a width of 100px.  The dropdown on the combobox however I would like to be about 300px wide.  It appears that the width of the dropdown is limited by the width of the actual combobox.

I've tried using templates to make the dropdown wider, but then it just puts a horizontal scrollbar in.

The reason I want this is that  for the dropdown we are displaying both a Code and the Description of the code such as "02343 - Some Descrition Here", but then when they select an option just the code goes into the combobox...  That being said we have everything working except for the width of the dropdown portion of the combobox.

Thanks
Jason
Top achievements
Rank 1
 answered on 24 Sep 2013
7 answers
1.3K+ views
I've managed to get the data through the read method, as already got the otherCRUD operations. However I want to know how to get the result (true or false) of an operation (create, update or delete) coming from my PHP script on the server. Here's the code:

Kendo:

 var JsonDataSource = new kendo.data.DataSource({
                        transport: {
                            read: {
                                url: "alunos_read.php", 
                                dataType: "json"
                            },
                            create: {
                                url: "alunos_add.php", 
                                type: "POST"
                            },
                            update: {
                                url: "alunos_update.php",
                                type: "POST"

      ...

PHP:

        mysql_query("update alunos set aluno = '".$aluno."' where cod_aluno = '".$cod_aluno."'");
$result = array('result' => (mysqli_affected_rows >= 0));
           
echo json_encode($result); // I want to get this overall result and show in an alert () functionHow do I do this?
KV
Top achievements
Rank 1
 answered on 24 Sep 2013
2 answers
127 views
I am getting an error after updating to the Q2 2013 SP. I was previously on Q2 2013.

Am I missing something? When I try to use kendo.core.js I get a syntax error.
Uncaught TypeError: Cannot set property 'en-US' of undefined kendo.core.js:472
Where line 472 is the following. kendo.cultures hasn't been initialized anywhere.
kendo.cultures["en-US"] = {
Prior to this release that line read:
kendo.cultures = {"en-US" : {

Am I mistaken or missing a dependency?
Ryan
Top achievements
Rank 1
 answered on 24 Sep 2013
1 answer
145 views
Hello,

Is there i way to get the numerictextbox so it starts with 01-02-03 etc?

Thanks
Georgi Krustev
Telerik team
 answered on 24 Sep 2013
5 answers
607 views
Please don't think I am a jaded customer because I love how using Kendo UI has made me look much better than I am by using your awesome controls.  However, I am using the new scheduler and I am a little frustrated with the (beta) documentation.  So I am finding myself relying on this forum.  Please help.

I need to repopulate the scheduler when a new user has been selected in a companion grid on the page.  I get the selection event with no problem.  Now I just need to know the best way to tell the scheduler to retrieve fresh data from the server based upon the value in the selection event.  After reading through much of the documentation and many of these threads I have come to the conclusion I need to set the dataSource to "serverFiltering: true" and then simply set a new filter.  That didn't call my "Get" function so I tried to force a read call directly.  Still nothing.  Am I approaching this correctly?  What is the best way to handle this?
function onSelectProvider(arg) {
 
     $("#scheduler").filter = { field: "Idd", operator: "eq", value: arg.Text };
     $("#scheduler").dataSource.read();
 }
Entilzha
Top achievements
Rank 2
 answered on 24 Sep 2013
1 answer
97 views
Hello,
I am trying to familiarise myself with the kendo ui dataSource, I have never before used JSON and have constructed the following using your documentation:

Html:
<!doctype html>
<html>
    <head>
        <title>Kendo UI Web</title>
        <link href="styles/kendo.common.min.css" rel="stylesheet" />
        <link href="styles/kendo.default.min.css" rel="stylesheet" />
        <script src="js/jquery.min.js"></script>
        <script src="js/kendo.web.min.js"></script>
    </head>
    <body>
        <div id="grid"></div>
        <script>
        $(document).ready(function () {
            var myDataSource = new kendo.data.DataSource({
                transport: {
                    read: {
                        url: "people.json",
                        dataType: "json"
                    }
                }
            });
 
            $("#grid").kendoGrid({
                dataSource: myDataSource,
                    columns: [
                    {
                        field: "firstName",
                        title: "First Name"
                    },
                    {
                        field: "lastName",
                        title: "Last Name"
                }]
            });
 
        });
 
    </script>
    </body>
</html>
Json File:
{
    "people": [
        { "firstName":"John" , "lastName":"Doe" },
        { "firstName":"Anna" , "lastName":"Smith" },
        { "firstName":"Peter" , "lastName":"Jones" }
    ]
}
The grid doesn't load any data, all I see are the headers.

I have tried this using simply HTML and a JSON file, I have also tried this in Visual Studio.

Any help would be appreciated,
Andrew.
Andrew
Top achievements
Rank 1
 answered on 24 Sep 2013
1 answer
157 views
Hello.

We need an option to make the datasource immediately drop the current in-flight data fetch request if another one comes in.

Currently, if the user clicks around several times in a row changing grid datasource parameters too quickly, several requests get fired off, but the grid waits for the very first request to complete before issuing the next one. This makes the user's wait time twice as long and also makes the grid content appear to switch back and forth as requests complete one after another. Very unpleasant effect.

Thank you.
Petur Subev
Telerik team
 answered on 24 Sep 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?