Telerik Forums
UI for ASP.NET MVC Forum
11 answers
3.0K+ views

I have an MVC grid that has an Ajax datasource with InCell editing.  After the grid loads we want to be able to update the contents of cells with JavaScript.  So the user will enter a value in a textbox.  Click a button that will execute JavaScript.  The JavaScript will then update the cells in the grid with the value from the textbox.  The idea being that this will save the user from typing the same value into every cell. 

Below is the JavaScript function I have.  It's looping through the grid and changing the value in cell named "NonOutageCost".  If I don't refresh the grid - then I don't see that the value has changed until I click in the cell.  After I click in the cell - then it shows me the value the JavaScript function set.  But it doesn't show the red dirty flag indicator.  If I refresh the grid - then it shows me the value the JavaScript function set.  But it doesn't show me the red dirty flag indicator.

Is there a way to have a JavaScript function that is executed by a button click change the cell contents and set the dirty flag indicator?  If so, could you show me an example.  I've spent a lot of time researching this and looking at the documentation.  But I haven't found an example like this.  Most of the examples I saw show doing something like this in a databound event.  But that won't work in this case.  Thanks for your help.

        function myFunction() {
            alert("Function executes when button is clicked");           
            var vgrid = $("#grid").data("kendoGrid");
            //Getting grid items
            var items = vgrid.dataSource.data();
            alert("length = " + items.length);
            alert("Non Outage Cost = " + ($('#NonOutageCostInput').val()));
            for (i = 0; i < items.length; i++) {
                var item = items[i];
              
                if ($('#NonOutageCostInput').val() > 0) { 
                    item.NonOutageCost = $('#NonOutageCostInput').val(); 
                }
            }
            //Refresh will change the row values - but the dirty flag isn't set - so the Save Changes doesn't update the database
            //alert("before refresh");
            //$("#grid").data("kendoGrid").refresh();
        }

Konstantin Dikov
Telerik team
 answered on 11 Feb 2019
1 answer
385 views

Hi,

i've managed to shrink the size of one column in timeline view, but my first row height still stays the same, so now the first cell in not aligned with others. (look at the screenshot)

 

Dimitar
Telerik team
 answered on 11 Feb 2019
2 answers
843 views

I have an application where I use TreeList and Grid. On both of them we have used Selectable and we have a custom command. On the TreeList if you press the custom command the full row is selected. Now we want to have the same functionality on the Grid but can not find why on the TreeList it works and not on Grid.

After further investigation I have found that the reason is because the treelist generates buttons ("<button>") while the grid generates links("<a>").

I have around 30 pages with grids with variable number of custom commands on them, with the possibility for more pages to be developed. How can I make the row selection functionality automatically on any page with grids like the TreeList.

Dan
Top achievements
Rank 1
Iron
Iron
Veteran
 answered on 11 Feb 2019
10 answers
1.0K+ views

Hi, this seems like it should be easy to do, but all the suggestions I've tried have failed.  I simply want to move items from searchResults to Assigned when the user double clicks on an item in searchResults.  The examples I've seen have all been for Kendo for Jquery and I keep getting errors on the "wrapper" piece.

 

Any help would be appreciated.

@(Html.Kendo().ListBox()
    .Name("searchResults")
    .BindTo(new List<TPResourceVM>())
    .DataValueField("Id")
    .DataTextField("FullName")
    .HtmlAttributes(new { style = "height:600px;width:40%" })
    .Toolbar(toolbar =>
    {
        toolbar.Position(Kendo.Mvc.UI.Fluent.ListBoxToolbarPosition.Right);
        toolbar.Tools(tools => tools
            .TransferTo()
            .TransferFrom()
        );
    })
    .Selectable(ListBoxSelectable.Multiple)
    .ConnectWith("assigned")
 
)
 
@(Html.Kendo().ListBox()
    .Name("assigned")
    .HtmlAttributes(new { style = "height:600px;width:40%" })
    .DataValueField("Id")
    .DataTextField("FullName")
    .Selectable(ListBoxSelectable.Multiple)
 
)
Tsvetomir
Telerik team
 answered on 08 Feb 2019
1 answer
252 views

0) Shouldn't the theme builder also allow us to change default fonts, font sizes, line heights, etc? 

1) The themes builder itself doesn't appear to change ALL colors. For instance, the chart grid lines, scrollbars, etc. This is especially annoying in dark themes. Some controls' text, as well as grid lines can't be seen, and scrollbars keep their "light" appearance.

Tsvetomir
Telerik team
 answered on 07 Feb 2019
1 answer
2.1K+ views

I want to create dynamic grid in ASP .Net MVC using Kendo grid. No of Columns are not fixed. It will get from database based on some conditions.

What will be the correct way to do it?

Also, If any of column has image url, in that case i want to display fixed size image 

Georgi
Telerik team
 answered on 07 Feb 2019
3 answers
181 views

I recently upgraded from a 2016 version of Kendo to 2018.

All foreign key values that were bound to int? (notice the ?, this is specific to Nullable<T>) are not saving.

I managed to fix this in some cases by adding the bolded:

columns.ForeignKey(p => p.IndexId, (System.Collections.IEnumerable)ViewData["indexNames"], "Id", "Name").Title("Index").Width(60).HtmlAttributes(new { data_value_primitive = "true" });

In some cases though, the bold doesn't work.

So my question is why do primative FK columns involving Nullable<T> (seems to be primitives only, as GUID? as FKs work) break when they used to work?

Konstantin Dikov
Telerik team
 answered on 07 Feb 2019
3 answers
384 views

I have problem with running the  TelerikMvcWebMail application .

I opened application with VS 2017

When try run it , the following error  occurs: “Unable to find version '2018.3.911' of package 'Telerik.UI.for.AspNet.Mvc5.Trial'.”

When I tried the install/update the (the package source Telerik.com defined and have connection to the server https://nuget.telerik.com/nuget)  I also got the error:

Severity Code Description Project File Line Suppression State
Error NuGet Package restore failed for project TelerikMvcWebMail: Unable to find version '2018.3.911' of package 'Telerik.UI.for.AspNet.Mvc5.Trial'.  https://www.nuget.org/api/v2/curated-feeds/microsoftdotnet/: Error downloading 'Telerik.UI.for.AspNet.Mvc5.Trial.2018.3.911' from 'https://www.nuget.org/api/v2/curated-feeds/microsoftdotnet/'.  The ServicePointManager does not support proxies with the https scheme.  https://api.nuget.org/v3/index.json: Package 'Telerik.UI.for.AspNet.Mvc5.Trial.2018.3.911' is not found on source 'https://api.nuget.org/v3/index.json'.  https://nuget.telerik.com/nuget: Unable to load the service index for source https://nuget.telerik.com/nuget.  An error occurred while sending the request.  The request was aborted: The request was canceled.  This method is not supported by this class.. 0

Can you help me please to solve the problem?

 

Izabel
Telerik team
 answered on 07 Feb 2019
4 answers
274 views

I have an issue where a grid's datasource hasChanges function is not working in IE, but does work in Chrome.

When leaving the page, I check to see if there are changes to the grid's data source, and if there are changes I prompt to make sure they want to leave with unsaved changes.  In this example, I save changes successfully and the hasChanges still returns true after the save is complete. 

 

Controller update function:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Minimum_Create([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<MinimumsViewModel> records)
{
    try {
        CDIWholesaleServiceClient client = new CDIWholesaleServiceClient();
        if (records.Any())
        {
            foreach (var record in records)
            {
                record.contractID = int.Parse(Request["globalContractID"]);
                var input = WholesaleDataMapper.ConvertMinimumRate(record);
                var output = client.InsertMinimumRate(input);
                record.id = output.MinimumID;
            }
        }
 
        return Json(records.ToDataSourceResult(request, ModelState));
    }
    catch(Exception ex)
    {
        ModelState.AddModelError("Minimum Creation Error", ex.Message);
        return Json(records.ToDataSourceResult(request, ModelState));
    }
 
}

 

 

Client Code:

function goodbye(e) {
    var minimumsGrid = $('#MinimumsGrid').data().kendoGrid;
    if (minimumsGrid.dataSource.hasChanges()
    ) {
        LeavingUnsavedNotify(e);
    }
}
window.onbeforeunload = goodbye;
 
@(Html.Kendo().Grid<WholesaleWeb.Models.MinimumsViewModel>(Model.minimums)
                                                .Name("MinimumsGrid")
                                                .Columns(columns =>
                                                {
                                                    columns.Command(command => command.Destroy()).Width(90);
                                                    columns.ForeignKey(x => x.timeUnitID, Model.minimumsTimeUnits, "Key", "Value").Title("Time Unit").Width(100);
                                                    columns.ForeignKey(x => x.qtyTypeID, Model.minimumsQtyTypes, "Key", "Value").EditorTemplateName("MinimumsQuantityType").Title("Qty Type").Width(100);
                                                    columns.ForeignKey(x => x.unitID, Model.minimumsByTypes, "Key", "Value").EditorTemplateName("MinimumsBy").Title("By").Width(100);
                                                    columns.Bound(x => x.minDollarAmt).EditorTemplateName("PositiveNumber").Title("Min").Width(80);
                                                    columns.Bound(x => x.feePerExam).EditorTemplateName("PositiveNumber").Title("Fee Per Exam").Width(120).Editable("feePerExamEditable");
                                                })
                                                .Editable(editable => editable.Mode(GridEditMode.InCell))
 
                                                .Pageable()
                                                .Navigatable()
                                                .Reorderable(reorder => reorder.Columns(true))
                                                .Sortable()
                                                .Scrollable()
                                                .Editable(editable => editable.DisplayDeleteConfirmation(true))
                                                .Resizable(resize => resize.Columns(true))
 
                                                .ToolBar(toolbar =>
                                                {
                                                    toolbar.Create();
                                                })
 
                                                .DataSource(dataSource => dataSource
                                                    .Ajax()
                                                    .Batch(true)
                                                    .PageSize(10)
                                                    .ServerOperation(false)
                                                    .Events(events => events.Error("error_handler").RequestEnd("MinimumRates_End"))
                                                    .Model(model =>
                                                    {
                                                        model.Id(x => x.id);
                                                    })
                                                    .Create(create => create.Action("Minimum_Create", "Wholesale").Data("getGlobalContractID"))
                                                    .Update(update => update.Action("Minimum_Update", "Wholesale").Data("getGlobalContractID"))
                                                    .Destroy(destroy => destroy.Action("Minimum_Destroy", "Wholesale").Data("getGlobalContractID"))
                                                )
                                                .HtmlAttributes(new { style = "width:100%" })
                                )

 

Viktor Tachev
Telerik team
 answered on 07 Feb 2019
1 answer
1.1K+ views

I have a Grid that I need to create a URL where part of the URL is part of the Bound Data from another field.  

 

So for example I have the Bound column \\#= MAPNAME \\# that will have the data   A30-32-A1 and I need to get the first 3 characters A30 

In my VB head I just want to use a LEFT string command. Is there a way to do a manipulation to get this to be part of the URL I am trying to concatenate? 

Here is  snippet of the line I am trying to edit and below that the Grid call (all of the code)  I don't really want to have to edit the controller or model... any suggestions?

columns.Bound(m => m.GRIDPRTID)
                  .ClientTemplate("<a href='" + Url.Content("http://gis.xxxxxx.com/GISGateway/GridPrints/IN NEED THE A30 HERE/A30-32-A1.pdf") + "' target='_blank'>\\#= MAPNAME \\#.pdf</a>");

 

@(Html.Kendo().Grid(new List<GRIDPRINTS>())  //<GISPortal.GRIDPRINTS>()
            .Name("grid_#=WOID#") // template expression, to be evaluated in the master context
 
            .Columns(columns =>
            {
                columns.Bound(o => o.GRIDPRTID).Width(110).Title("GridID");
                columns.Bound(o => o.MAPNAME).Width(110).Title("Name");
                columns.Bound(o => o.GRIDID).Width(110).Title("GridID");
                columns.Bound(o => o.SCALE).Width(110).Title("Scale");
                columns.Bound(o => o.PAGENUMBER).Title("PgNum");   
                columns.Bound(o => o.STATUS).Width(200).Title("Status");
                columns.Bound(o => o.ERRORS).Width(300).Title("Errors?");
 
 
                columns.Bound(m => m.GRIDPRTID)
                  .ClientTemplate("<a href='" + Url.Content("file://macfap01/GIS/GridPrints/A21/\\#= MAPNAME \\#.pdf") + "' target='_blank'>\\#= MAPNAME \\#.pdf</a>");
 
 
 
 
 
                columns.Bound(m => m.MAPNAME).Hidden()
                  .ClientTemplate("<input type='hidden' "
                  + "name='MAPNAME[\\#= GRIDPRTID \\#]' "    //                  + "name='THEMAPNAME[\\#= GRIDPRTID \\#].MAPNAME' "
                  + "value='\\#= MAPNAME \\#' />");
 
                columns.Bound(m => m.PAGENUMBER).Hidden()
                  .ClientTemplate("<input type='hidden' "
                  + "name='PAGENUMBER[\\#= GRIDPRTID \\#]' "    //   + "name='THEPAGENUMBER[\\#= GRIDPRTID \\#].PAGENUMBER' "
                  + "value='\\#= PAGENUMBER \\#' />");
 
                columns.Bound(m => m.SCALE).Hidden()
                  .ClientTemplate("<input type='hidden' "
                  + "name='SCALE[\\#= GRIDPRTID \\#]' "   //+ "name='THESCALE[#=gridIndex(data)#].SCALE' "
                  + "value='\\#= SCALE \\#' />");
 
                columns.Bound(m => m.WOID).Hidden()
                  .ClientTemplate("<input type='hidden' "
                  + "name='WOID[\\#= GRIDPRTID \\#]' "   //+ "name='THESCALE[#=gridIndex(data)#].SCALE' "
                  + "value='\\#= WOID \\#' />");
 
                columns.Bound(o => o.MAPNAME).Width(110).Title("ReSend")
                     .ClientTemplate("<input type='checkbox' "
                     + "name='checked[\\#= GRIDPRTID \\#]' "    //                     + "name='CHECKED\\#= WOID \\#.MAPNAME' "
                     + "value='true' "
                     + "#if (WOID) { #checked='checked'# } #/>"
                     + "<input type='hidden' value='false' "
                     + "name='checked[\\#= GRIDPRTID \\#]' />");   //                     + "name='themapname\\#= WOID \\#.MAPNAME' />");
 
            })
            .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(10)
                .Read(read => read.Action("GRIDPRINTS_Read", "GridPrint", new { woid = "#=WOID#" }))
                .ServerOperation(false)
            )
            .Pageable()
            .Sortable()
            .ToClientTemplate()
    )
Jason
Top achievements
Rank 1
 answered on 06 Feb 2019
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
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
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?