Telerik Forums
UI for ASP.NET MVC Forum
4 answers
1.0K+ views
Hello again,
if i want to pass inside a javascript function,a string parameter how can i do that?

for example this sentence
.ToolBar(toolBar => toolBar.Template("<a class='k-button k-button-icontext k-grid-add' onclick='addCustomCheckBoxField('IsHour')' href='javascript: void(0)'><span class='k-icon k-add'></span>add</a>"))

gives me an syntax error.
i would like to pass the IsHour as a string value for the function.
Maybe it is more a javascript problem,but it is used in kendo ui context.

Regards,
Daniel
Daniel
Top achievements
Rank 1
 answered on 29 Apr 2013
1 answer
444 views
I am using the kendo mvc grid .I want implement the scroll bar  but data part is scrolling properly but hearer of grid is not scrolling with data.

@(Html.Kendo().Grid(Model) 
    .Name("gridSyndromic")
    .Columns(columns =>
    {
        columns.Bound(p => p.Syndromes.Name).Title("Syndromes").Width(210);
        columns.Bound(p => p.Symptoms3).Title("No of Clients With").Width(210)
              
        
        columns.Command(command => { command.Edit(); command.Destroy(); }).Width(172);
    })
                           .ToolBar(toolbar =>
                           {
                               toolbar.Create();

                           })
    .Editable(editable => editable.Mode(GridEditMode.InLine))
    .Pageable()
    .Sortable()
    .Scrollable()
    .Resizable(p=>p.Columns(true))
    .HtmlAttributes(new { style = "height:506px;width:400px;" })
    .DataSource(d => d.Server().PageSize(10).Create(update => update.Action("EditingInline_Create", "Syndromic"))
                        .Read(read => read.Action("Index", "Syndromic"))
                        .Update(update => update.Action("EditingInline_Update", "Syndromic")).Destroy(update => update.Action("EditingInline_Destroy", "Syndromic"))
                        .Model(model => model.Id(p => p.SymptomsId)))
     


Thanks
Dimo
Telerik team
 answered on 29 Apr 2013
4 answers
372 views
My upload works but fires the error event and not success.
the controller returns a empty contentresult, I get no server or js errors. Upload fires error event and shows retry, yet image is uploaded and saved to database

any help. thanks

Function ImageUpload(uploadedImages As BO.Models.UploadedImage) As ContentResult
    If uploadedImages.Image.Last.ContentType.StartsWith("image/", StringComparison.OrdinalIgnoreCase) Then
        Dim imageBytes As Byte() = BO.Factory.Image.ResizeImage(194, 194, uploadedImages.Image.Last.InputStream, Drawing.Brushes.White, Drawing.Imaging.ImageFormat.Png)
        Dim thumbBytes As Byte() = BO.Factory.Image.ResizeImage(100, 100, uploadedImages.Image.Last.InputStream, Drawing.Brushes.White, Drawing.Imaging.ImageFormat.Png)
        BO.Factory.ContractorFactory.SaveImages(imageBytes, thumbBytes, uploadedImages.ContractorId)
    End If
    Return Content(String.Empty)
End Function
 
Function ImageRemove(uploadedImages As BO.Models.UploadedImage) As ContentResult
    Return Content(String.Empty)
End Function


    <img alt="@Model.Name" data-upload-image="true" src="@Url.Action("image", New With {.controller = "contractor", .area = "contractor", .id = Model.ContractorId})" />
    @code
        Dim imageUploada As Kendo.Mvc.UI.Upload = Html.Kendo.Upload().Name("Image") _
                                                  .Multiple(False) _
                                                  .Async(Function(y) y.AutoUpload(True) _
                                                             .Save("imageupload", "contractor", New With {.area = "contractor", .contractorid = Model.ContractorId}) _
                                                             .Remove("imageremove", "contractor", New With {.area = "contractor", .contractorid = Model.ContractorId})) _
                                                         .Events(Function(events) events.Success("imageUploaded").Error("onUploadError"))
        imageUploada.Render()
    End Code
</div>
<script>
    function onUploadError(e) {
        alert(e.operation)
        alert(e)
        alert(getFileInfo(e))
    }
 
    function imageUploaded(e) {
        $("img[data-upload-image]").each(function (index) {
            var url = $(this).attr("src") + '?' + Math.random() * 1000000;
            $(this).attr("src", url);
        });
    }
 
    function getFileInfo(e) {
        return $.map(e.files, function (file) {
            var info = file.name;
 
            // File size is not available in all browsers
            if (file.size > 0) {
                info += " (" + Math.ceil(file.size / 1024) + " KB)";
            }
            return info;
        }).join(", ");
    }
 
</script>
Nicholas
Top achievements
Rank 2
 answered on 28 Apr 2013
0 answers
271 views
Hi everyone,

I have some problems on using Kendo UI Grid. The first problem is when I click on page number at bottom tool bar of grid, the grid was loading for data base on page index; but while data is loading, I just suddenly clicked on another page number, then the grid is mess up with data from page index; data of this page index is viewed for data of other page index, and the page number buttons also changed automatically. It was just look like a real mess on the grid.

EG: If I click on page index 10, and while data is loading, I suddenly click on page index 6. Then the number 6 is change to red color, but the data is viewed for page 10.

EG: If grid is viewing data of page index 1, and I click page 10. While data is loading for page, I click on page 6. Then the data is viewed for page 10, but the page number button is changing red color at page 1 then jump at page 6 and then jump at page 10.

It just look like a graphic error on Kendo UI Grid. So I end up here to ask for a help.

My solution is disable all page index buttons while data in grid is loading. For example, if click on page 10 then other page number from 1 - 100 must be disable except page 10. But if the grid is finished loading, then all page number must be re-enable.

Is there JavaScript function to detect while Kendo Grid is loading data, and how to disable page index buttons, and how to re-enable page index buttons?

I need your help on my issue.

Tri
Tri
Top achievements
Rank 1
 asked on 28 Apr 2013
1 answer
144 views
This code library project (http://www.kendoui.com/code-library/permalink/NkytUzlZ1ESWI9C7cOx7MQ) works fine with the 2012.2.913 version of the MVC wrapper and script library, but it doesn't work with the 2013.1.319 version of the MVC wrapper and script library.

The thing that i've noticed with this version of the wrapper is the ModelState object is not being serialized properly by the .ToDataSourceResult() method and it returns a null value, in turn the .Json() method is returning an empty result set to the client.

Is this a bug with the .ToDataSourceResult() method? or is there a new way to return ModelState information that I'm not aware of?
Daniel
Telerik team
 answered on 26 Apr 2013
2 answers
239 views
Hello:

I have a Master/Child grid structure like so:

Parent Grid:
 @(Html.Kendo().Grid<ElementViewModel>()
.Name("gridEle")
.Columns(cols =>
{
    cols.Bound(e => e.EleNum)
})
.DataSource(dataSource => dataSource
    .Ajax()
    .Read(read => read.Action("GetElements", "Rating", pi))   
)
.ClientDetailTemplateId("tempSubEle")          
)

Child Grid as DetailTemplate:


<script id="tempSubEle" type="text/kendo-tmpl">
 
@(Html.Kendo().Grid<SubElementViewModel>()
.Name("gridSubEle_#=EleID#")
.Columns(cols =>
{
    cols.Bound(e => e.Rating)      
        .ClientTemplate("<input type='checkbox' value='1' " +
                        "#if(Rating==1){#checked='checked'#}# />" );
})
.DataSource(dataSource => dataSource
            .Ajax()
            .Read(read => read.Action("GetSubElementsByElementID", "Rating", new { eID = "#= EleID #" }))
)
.ToClientTemplate()
)
    </script>
The Problem:

I have a #if{# ... #}# statement in the column ClientTemplate, however the Rating value is from the Parent Grid not the current Child Grid (Parent Grid happen has a column also named 'Rating'), to prove that it is from Parent Grid,  if I change Rating to a column that only exists in the Child grid, i.e. SubEleID, it gives error at browser, saying that SubEleID is not found.

The Question:
so what is the syntax for Rating gets the Child Grid value?
just for the sake of trying, I even tried: data.Rating, or $(this).Rating, none worked.

Please advise,
Thank you

HSO
Top achievements
Rank 2
 answered on 26 Apr 2013
2 answers
318 views
Hi,
I am trying to use the Kendo UI Grid with ASP.NET MVC to replace an existing MVC WebGrid which displays a set of data with each row having a Submit button. The Submit button can be displayed as enabled or disabled and when pressed, the form is posted back to the Controller with the selected row identity stored in a a data item.

I can't see how to achieve this relatively simple requirement using the Kendo UI Grid.

The existing code for the MVC WebGrid is below and allows easy definition of the Submit button for each row by using the @item. syntax which is available for the WebGrid.

Is there an equivalent example for the Kendo UI Grid with MVC that shows how you display a submit button (enabled/disabled based on a row property),  submit the form, and then passback the selected row identity to the controller ?

Thanks,
Kevin Wood

@model Vsat_2.Models.AgentTeams
<div id="SearchTeams">
    <div>
        <div id="criteria">
        @Html.HiddenFor( model => model.CompanyId)@Html.HiddenFor( model => model.RegionId )@Html.HiddenFor( model => model.Selection )
        @Html.HiddenFor( model => model.SearchVal)@Html.HiddenFor( model => model.SearchCritId )@Html.HiddenFor( model => model.RowsPerPage )@Html.HiddenFor( model => model.CurrentPage )
        @Html.HiddenFor( model => model.TeamSearch.CompanyId)@Html.HiddenFor( model => model.TeamSearch.RegionId )
        Search @Html.DropDownListFor(model => model.TeamSearch.SearchCritId, Model.TeamSearch.SearchCrit) for @Html.EditorFor(model => model.TeamSearch.SearchVal)
        <input type="submit" value="Search" name="submitButton" id="Search" /> @Html.ValidationMessageFor(model => model.TeamSearch.SearchVal)<span id="Searchwait" style="visibility:hidden"> Please wait..</span>
        </div>    
        <div id="status">
            <span id="statusmessage" style="padding-left:0.5em;color:black">@Html.LabelFor(model => model.TeamSearch.SearchResult, Model.TeamSearch.SearchResult)</span>
        </div>
        <p></p>
        <div id="MainGrid" style="float:left;width:100%">
@{
        var grid2 = new WebGrid(canPage: true, rowsPerPage: Model.TeamSearch.rowsperpageid, canSort: true, defaultSort: "SearchCrit", ajaxUpdateContainerId: "grid3", pageFieldName: "TeamPage");
        grid2.PageIndex = Model.TeamSearch.page;
        grid2.Bind(Model.Teams, rowCount: Model.TeamSearch.TotalRows, autoSortAndPage: false);
        grid2.Pager(WebGridPagerModes.All, numericLinksCount: 10);

        @grid2.GetHtml(htmlAttributes: new { id = "grid3" },
                       columns: grid2.Columns(
                       grid2.Column("InternalName", header: "Agent Team", canSort: false), 
                       grid2.Column(format: @<input type="submit" @item.Disabled onclick="mySelection='@item.Identity'" value="Select Team" name="submitButton" id="Change" style="font-size:90%" />),
                       grid2.Column("Reason", canSort: false) 
                       @*grid2.Column("Name", header: "ID", canSort: false) *@
                       ));
        }
        </div>
    </div>
</div> 

<script>
    var mySelection;

    $(function () {
        $("#Change").live('click', function () {
            $("#Audit").html(""); //Clear Audit Screen
            $("#Search").css({ "visibility": "hidden" });
            $("#Searchwait").css({ "visibility": "visible" });
            $("#Selection").val(mySelection); //Set the Selection field
        });
    });

$(function () {
        $("#Search").live('click', function () {
            $("#Audit").html(""); //Clear Audit Screen
            $("#Search").css({ "visibility": "hidden" });
            $("#Searchwait").css({ "visibility": "visible" });
        });
});


</script>
Kevin
Top achievements
Rank 1
 answered on 26 Apr 2013
7 answers
1.2K+ views
Hi,

I have a grid that is populated from my Controller. My controller gets its data from an external webservice, and then populates a list in my controller, and then the view is fed with this list.

This is my controller:
public ActionResult Index()
{
    var client = new UnitServiceClient();
    var listOfUnitsFromService = client.GetListOfUnits(true);
 
    var model = new UnitModel
                    {
                        UnitTypes = listOfUnitsFromService.ToList()
                    };
        return View(model);
}
And this is my grid (cshtml):
<div class="row-fluid">
    <div class="span12">
        <div class="k-block">
            <div class="k-header">Unit List</div>
            @(Html.Kendo().Grid(Model.UnitTypes)
            .Name("Grid")
            .Columns(columns =>
                {
                    columns.Bound(p => p.Id).Groupable(false);
                    columns.Bound(p => p.Name);
                    columns.Command(command => { command.Custom("Edit Unit"); }).Width(160);
                })
                .Groupable()
                .Pageable()
                .Sortable()
                .Scrollable()
                .Filterable()
                )
        </div>
    </div>
Populating the grid when the page is loaded is no problem, but I'd like to update my grid with a new list of units whenever the user clicks the checkbox. Any help would be appreciated :)
Nicklas
Top achievements
Rank 1
 answered on 26 Apr 2013
9 answers
386 views
Dear Kendo Team,

I'm using a simple grid, which I binded with few thousand records, and added a Change event. Below is the code.
@(Html.Kendo().Grid(Model.OtherCompanyVesselsModelList)
                      .Name("grdOtherCompanyVessels")
                      .Columns(columns =>
                      {
                          columns.Bound(p => p.ID).Visible(false).Width(50);
                          columns.Bound(p => p.VesselName).Width(150);
                          columns.Bound(p => p.IMONo).Width(100);
                      })
                              .Pageable(paging => paging.PageSizes(new int[3] { 50, 100, 500 }))
                              .Sortable()
                              .Selectable()
                              .Navigatable()
                              .Scrollable(scrollable => scrollable.Height(480))
                              .Reorderable(reorder => reorder.Columns(true))
                              .Resizable(resize => resize.Columns(true))
                              .Events(e => e.Change("onChange"))
                              .Filterable()
                              .DataSource(dataSource => dataSource
                                                            .Ajax()
                                                            .Read(read => read.Action("FetchOtherCompanyVesselDetails", "OtherCompanyVessels"))
                                                            )
                              )

Now in my Change event, I just kept one alert.

function onChange(e) {
        alert('In Change');
    }

But when I run the page in FireFox 19.0 and selects any row in the grid, it shows alert after long time(approx 10-15 seconds), and second time when I select any other row the FireFox itself stops responding. Finally I've to close FireFox.
And the same thing if I execute in Chrome 24.0, it works perfectly.
And in IE 9, the change event executes twice and prompt alert twice.

Grateful, if you assist me here.
I'm using Kendo.Mvc v4.0.30319 with VS2012.

Regards,
Suraj Kumar Singh.
saritha
Top achievements
Rank 1
 answered on 25 Apr 2013
1 answer
1.0K+ views
I have an aggregate on the quantity column returning the sum. Is it possible for it to only return the total for one groupings instead of returning a total for each of my groupings? I would just like a total for the ShippedDate grouping.
        
/// Code ///
01.        @(Html.Kendo().Grid(Model)
02.    .Name("Grid")
03.    .HtmlAttributes(new { style = "width:80%" })
04.    .Columns(columns =>
05.    {
06.        columns.Bound(p => p.CountyID);
07.        columns.Bound(p => p.County);
08.        columns.Bound(p => p.OrderNum);
09.        columns.Bound(p => p.ShippedDate).Format("{0:MM/dd/yyyy}");
10.        columns.Bound(p => p.InvCode);
11.        columns.Bound(p => p.TagName);
12.        columns.Bound(p => p.Quantity)
13.            .ClientGroupFooterTemplate("Total: #=sum#");
14.    })
15.    .Groupable()
16.    .Pageable()
17.    .Sortable()
18.    .Filterable()
19.    .DataSource(dataSource => dataSource
20.        .Ajax()
21.        .Group(g => g.Add(p => p.CountyID))
22.          .Group(g => g.Add(p => p.County))
23.            .Group(g => g.Add(p => p.OrderNum))
24.              .Group(g => g.Add(p => p.ShippedDate))
25.         .Aggregates(aggregates =>
26.            {
27.                aggregates.Add(p => p.Quantity).Sum();
28.            })
29.        .Read(read => read.Action("CountyMonth_Read", "Report").Data("CountyMonthData"))
30.        .PageSize(10)
31. 
32.    )
33. 
34.)
Daniel
Telerik team
 answered on 25 Apr 2013
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
ComboBox
Upload
MultiSelect
ListView
Window
TabStrip
Menu
Installer and VS Extensions
Spreadsheet
AutoComplete
TreeList
Gantt
PanelBar
NumericTextBox
Filter
ToolTip
Map
Diagram
Button
PivotGrid
Form
ListBox
Splitter
Application
FileManager
Sortable
Calendar
View
MaskedTextBox
PDFViewer
TextBox
Toolbar
Dialog
MultiColumnComboBox
DropDownTree
Checkbox
Slider
Switch
Notification
Accessibility
ListView (Mobile)
Pager
Security
ColorPicker
DateRangePicker
Wizard
Styling
Chat
DateInput
MediaPlayer
TileLayout
Drawer
SplitView
Template
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Licensing
Rating
ScrollView
ButtonGroup
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
DateTimePicker
AppBar
BottomNavigation
Card
FloatingActionButton
Localization
MultiViewCalendar
PopOver (Mobile)
Ripple
ScrollView (Mobile)
Switch (Mobile)
PivotGridV2
FlatColorPicker
ColorPalette
DropDownButton
AIPrompt
PropertyGrid
ActionSheet (Mobile)
BulletGraph
Button (Mobile)
Collapsible
Loader
CircularGauge
SkeletonContainer
Popover
HeatMap
Avatar
ColorGradient
CircularProgressBar
SplitButton
StackLayout
TimeDurationPicker
Chip
ChipList
DockManager
ToggleButton
Sankey
OTPInput
ChartWizard
SpeechToTextButton
InlineAIPrompt
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
AICodingAssistant
SmartPasteButton
PromptBox
SegmentedControl
LLM Kit
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?