Telerik Forums
UI for ASP.NET MVC Forum
1 answer
611 views
When a user changes the order of columns in a grid, I was able to capture the new column order, serialize it, and store it.
I just can't figure out how to bring that data back and re-apply it to the grid when the page reloads.

I used the "columReorder"  event to post a service call to store the results.
 columnReorder: function (e) {
                var that = this;
                setTimeout(function () {
                    SaveColsGrid1(kendo.stringify(that.columns));
                }, 5);
            },

I've tried a couple ways to bring in columns.
I tried binding to kindo grid "columns" property, but an external web service call doesn't come back in time before the grid renders.
Am I going about this correctly or is there a better way to take a serialized list of columns (that i've saved) and set the order when the grid loads?

Thanks,
Ben
Dimo
Telerik team
 answered on 06 Jun 2014
2 answers
792 views
I have a People View that shows People in a Grid and each one has a standard Edit button.

(Guest)Index View
@model IEnumerable<PersonModelBase>
@using Kendo.Mvc.UI
@using SIS.Entities
@using SIS.Web.Models
...
    @(Html.Kendo().Grid<PersonModel>()
        .Name("peopleGrid")
        .Columns(columns =>
        {
            columns.Bound(p => p.ID).Hidden();
            columns.Bound(p => p.FullName)
                .HeaderTemplate("Name <input type='text' id='fullname' />")
                .Width(230);
            columns.Bound(p => p.DOB)
                .Format("{0: yyyy-MM-dd}")
                .HeaderTemplate("Date of Birth");
            // Define command columns
            columns.Command(commands =>
            {
                commands.Edit();
            })
                .Width(100);
        })
        //.Editable(editable => editable.Mode(GridEditMode.PopUp))
        .Editable(editable => editable
            .Mode(GridEditMode.PopUp)
            .DisplayDeleteConfirmation(true)
            .TemplateName("_AddEditPerson"))

The Edit button goes to the _AddEditPerson Partial View.  The PersonModel is successfully passed through with properties within the Model being displayed, including the ID (for debug purposes).

_AddEditPerson Partial View 
@model SIS.Web.Models.PersonModel
@using SIS.Web.Models
@using Kendo.Mvc.UI

display of ID from Model works fine

                @* ID *@
                <div class="form-group">
                    <label for="ID" class="col-sm-2 control-label">ID</label>
                    <div class="col-sm-10">
                        @Html.EditorFor(model => model.ID)
                    </div>
                </div>

but use of Model to pass through to Grid in TabStrip View does not

        @(Html.Kendo().TabStrip()
                    .Name("bottom-tabstrip")
                    .Items(tabstrip =>
                    {
                        tabstrip.Add().Text("Notes")
                            .Selected(true)
                            .Content(
                            @<text>
                                <div id="notesGrid" class="form-horizontal">
                                    @*ToDo*@
                                    @Html.Partial("Partials/_NotesGrid", Model.ID)
                                </div>
                            </text>);

The _AddEditPerson Partial View then calls some other partial views (e.g. see below) to show Grids for that Person within various tabs.

The issue is that when I try to pass through the ID (of the Person) through to those partials so that they can list items for that person, its null.  In fact the whole Model can be seen to be Null when I debug it.  If I hard card the ID being passed through it works, so its not an issue in getting it from the AddEdit to the Partial but in using model data for passing through.

What am I missing?

Thanks,

Chris.

_NotesGrid View
@model int
@using Kendo.Mvc.UI
@using ShilohIS.Web.Models

@(Html.Kendo().Grid<NoteModel>()
    .Name("notesgrid")
...
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("ReadRegarding", "Notes", new { id = Model }))
        .Create(create => create.Action("Create", "Notes"))
        .Update(update => update.Action(/* action */"Update", /* controller */ "Notes"))
        .Model(model =>
            {
                model.Id(note => note.ID);
                // Guest id
                model.Field(note => note.RegardingID).DefaultValue(Model);
                // Status
                model.Field(note => note.Status).DefaultValue(new SelectListItem());



Chris
Top achievements
Rank 1
 answered on 05 Jun 2014
3 answers
105 views
Is there a way to reference the toolbar from the Events function in order to change the text content of the toolbar?

Dan
Dimiter Madjarov
Telerik team
 answered on 05 Jun 2014
1 answer
72 views
Hi

i want to display a link in Grid field. now i have a IsReady Bool field in Model, on Grid read action model fetch with values.

now if this field is true then i want to show this link or if false then i want to hide it.
i want to use razor condition like this is @(IsReady) ? Style:" "  : Style: "display:none" but i can't use because there is "" ' ' error in kendo grid so can any one guide me .

my code is "<a href='' #= @("#=IsReady#").ToString().ToLower() ? 'style=\"display:none;\"' : '' #>link</a>"

Regards,
vinit
Krunal
Top achievements
Rank 1
 answered on 05 Jun 2014
2 answers
224 views
Hi,

I have an error on returning popup kendo window in javascript call from controller in kendo upload.

The scenario is I have a kendo window main popup where inside of it is kendo upload control.
during processing of uploading and validation of excel file, Im creating error list gathered from excel data
and returning all that lists as popup kendo window from controller (javascript call).

The problem is, the popup kendo window with the list of string is not functioning but returning as javascript file to upload.
I don't know what's the conflict between the main kendo window, kendo upload and the new kendo window that I called as error list window which
is not popping-up.

See my code below...

VIEW:


<script>
    

    $(document).ready(function () {
        var iProcess = true;

        var dialog = $("#ImportDetails").data("kendoWindow");
        dialog.center();

        $("#btnImportCancel").kendoButton({
            click: function (e) {
                dialog.close();
            }
        });

        var lookup = $("#ComboLookupTable").data("kendoComboBox");
      
        $("#files").kendoUpload({
            async: {
                saveUrl: "Lookup/UploadFile",
                removeUrl: "remove",
                autoUpload: false,
                value: 'Import'
            },
            localization: {
                select: "Select a file",
                uploadSelectedFiles: "Import"
            },
            multiple: false,
            select: function (e) {
                var kendoWindow = $("<div />").kendoWindow({
                    title: "Replace Lookup Table Data?",
                    height: 130,
                    width: 280,
                    resizable: false,
                    modal: true,
                    animation: {
                        open: {
                            effects: "fade:in",
                            duration: 500
                        },
                        close: {
                            effects: "slide:right fadeOut",
                            duration: 500
                        }
                    },
                    visible: false
                });

                kendoWindow.data("kendoWindow")
                    .content($("#delete-confirmation").html())
                    .center().open();

                kendoWindow
                    .find(".delete-confirm,.delete-cancel")
                        .click(function () {
                            if ($(this).hasClass("delete-cancel")) {
                                iProcess = false;
                                e.preventDefault();
                                kendoWindow.data("kendoWindow").close();
                                dialog.close();
                            }
                            else {
                                kendoWindow.data("kendoWindow").close();
                            }
                        })
            },
            upload: function (e) {
                 e.data = { additional: $("#ComboLookupTable").val() };
            },
            success: function (e) {
                var delay = 1500;
                setTimeout(function () {
                    e.preventDefault();
                    dialog.close();
                }, delay);
            },
            error: function (e) {
               
                var err = e.XMLHttpRequest.responseText;
                alert(err);
            }

        });
    });


function showErrorMsgsJson(messages, windowName) {
    showErrorMsgs($.parseJSON(messages), windowName);
}

function showErrorMsgs(messages, windowName) {
    var results = "";
    if (messages.length > 0) {
        results += "<ul class='list-group'>";
        $.each(messages, function (i, n) {
            //results += "<span>" + (i + 1) + ". " + n + "</span><br/>";
            results += "<li class='list-group-item'>" + (i + 1) + ". " + n + "</li>";
        });
        results += "</ul>";

        var formattedMessages = '<div style="height:305px; margin: 2px 2px 15px 2px; padding: 10px 10px; border:1px solid lightgray; ">' + results + '</div>'
        var closeButton =
            '<div style="text-align:center;">' +
            '    <button id="btnCloseMessages" type="button" class="k-button" onclick="closeWindow(\'' + windowDialog + '\');">&nbsp;&nbsp;Close&nbsp;&nbsp;</button>' +
            '</div>';

        $("#" + windowName).data(kendoWindow).content(formattedMessages + closeButton).center().open();
    }
}


</script>

from my CONTROLLER:


 <HttpPost>
    Public Function UploadFile(ByVal files As HttpPostedFileBase, ByVal additional As String) As ActionResult

        Dim data = (New ExcelReader()).ReadExcel(files)

       
                For Each datarow In data.DataRows
                    ent.Add(New ViewModel.FuelEfficiencyViewModel.Create With {.VehicleClass = datarow(0).ToString, _
                                                                               .FuelEfficiencyValue = If(datarow(1) <> Nothing, Convert.ToDecimal(datarow(1)), 0), _
                                                                               .CreatedBy = Session(LocalConstant.Ses_UserID), _
                                                                               .CreatedDate = Now.Date})
                Next

                'Validation here
                Dim _messages As List(Of String) = _fuelefficiencyRepository.ValidateEntity(ent)

                If _messages.Count = 0 Then
                    _fuelefficiencyRepository.Create(ent)
                    Return Content("")
                Else
                    'THIS IS WHERE THE ERROR OCCUR, new kendo window dialog is not popping-up but js file is occuring.
                      Return JavaScript("showErrorMsgsJson('" & _messages.ToJSON() & "','windowDialog')")
                    'NOTE, showGridErrorMsgs is javascript function to call new popup kendo window, see code above
                End If

    End Function
    
    
    
    I hope you could help me on this to pop-up new kendo window. See attached error image.



Dimiter Madjarov
Telerik team
 answered on 05 Jun 2014
1 answer
181 views
Hi

I am attempted to work with a treeview and it is not going very well.  I am using Datasource property to get the nodes of the treeview which works.  I want to be able to set the ImageUrl of the nodes.  This is something that I have been able to do in the past using BindTo and mapping the appropriate fields.

Is there some way to use the Datasource and set up a property mapping?  Unless I'm missing something, it seems like you are pretty limited with what you can do as far as setting any node properties other than the text using the Datasource.

Any help would be appreciated.
Alex Gyoshev
Telerik team
 answered on 05 Jun 2014
1 answer
301 views
Hello!
Tell me please. Can I add a layer with gps track on the map? Thank you!
T. Tsonev
Telerik team
 answered on 04 Jun 2014
2 answers
106 views
I cant get labels to render correctly.

series.Pie(Function(model) model.Value, Function(model) model.Key).Labels(Function(labels) labels.Template("#= Key #: #= Value #").Visible(True))

This gives me an error "JavaScript runtime error: 'Value' is undefined"
if I remove Value and use "#= Key #" I get I get a label like "[object Key]"

Thanks


Alan Mosley
Top achievements
Rank 1
 answered on 04 Jun 2014
1 answer
71 views
Wondering where the MVC samples went to on the Kendo component demo pages?  

It was an excellent quick reference for the MVC Wrappers fluent syntax.

Also hopping this does not signify the beginnings of sun-setting MVC support, please confirm this is not the case!

http://demos.telerik.com/kendo-ui/ 
Sebastian
Telerik team
 answered on 04 Jun 2014
1 answer
96 views
I am trying to refresh a chart using ajax, but cant seem to send data. Where am I going wrong, I have tried many things to pass data, but all have failed
I am trying send dates

$(document).ready(function () {
 
 
    var pieUrl = "@pieUrl";
    var dataSource = new kendo.data.DataSource({
        transport: {
            read: {
                url: pieUrl,
                dataType: "json"
            }
        }
    });
    dataSource.read({"FromDate": kendo.toString($("#FromDate").data("kendoDatePicker").value(), "dd/MM/yyyy"), "ToDate": kendo.toString($("#ToDate").data("kendoDatePicker").value(), "dd/MM/yyyy") })
 
 
    var chart = $("#EnrolmentsValue").data("kendoChart");
    chart.setDataSource(dataSource);
    chart.redraw();
    chart.refresh();
})

My chart
@code
 
    Dim EnrolmentsValue As Kendo.Mvc.UI.Chart(Of BO.Models.Statistics.KeyValue) = _
                Html.Kendo().Chart(Of BO.Models.Statistics.KeyValue).Name("EnrolmentsValue").Title(Sub(title)
                                                                                                           title.Text("Share of Internet Population Growth, 2007i - 2012").Position(ChartTitlePosition.Bottom)
                                                                                                   End Sub).
                                                               Legend(Sub(legend)
                                                                              legend.Visible(False)
                                                                      End Sub).
                                                               Series(Sub(series)
                                                                              series.Pie(Nothing).Labels(Sub(labels) labels.Template("#= Key #: #= Value#%").
                                                                                         Background("transparent").Visible(True)).StartAngle(150)
                                                                      End Sub).Tooltip(Function(tooltip) tooltip.Visible(True).Format("{0}%")).AutoBind(True).
                                                                      DataSource(Sub(ds)
                                                                                         ds.Read(Function(read) read.Action("getsalesbyfranchisee", "statistics", New With {.area = String.Empty}))
                                                                                 End Sub)
 
 
    EnrolmentsValue.Render()
 
 
    Dim pieUrl As String = Url.Action("getsalesbyfranchisee", "statistics", New With {.area = String.Empty})
 
end code





Alan Mosley
Top achievements
Rank 1
 answered on 03 Jun 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?