Telerik Forums
UI for ASP.NET MVC Forum
5 answers
877 views

Hi, I have been trying to change the label steps of my category axis but I cannot find a way in the API to do this except for setting the steps to a fixed number .Labels(label => label.Step(12)).

Is there some built in way to do this or should I create a javascript function that returns the steps and then try to access that inside the razor expression? 

Stamo Gochev
Telerik team
 answered on 30 Oct 2018
2 answers
164 views

Hi,

I have a grid where I want a link in some of the cells in one column. The logic for deciding the link is quite complex, so I wanted to have that logic in the read method for the grid in the controller. It was a bad idea for some reasons, but the strange thing is that the update and destroy methods of the grid stopped working. They were not called at all.

I fooled around a bit and found that if you have a property in the view model that is not even shown in the grid and you have a link in that property the update and destroy methods stop working - they are not called.

The project is quite large, so I have attached only the relevant code snippets. You should be able to test just by adding a string property in any view model and set the value to a link like it is done in the example.

My question is: Is this the desired behaviour of the grid or if I have stumbled on a bug.

Best regards,

Henrik

 

Henrik
Top achievements
Rank 1
 answered on 30 Oct 2018
4 answers
221 views
I have a dropdown list within a tab strip which in some way has a transparent background. The actual control is in front of the grid behind because if I click on the dropdown items they react and everything works correct but I am trying to get the dropdown to not be transparent.
Veselin Tsvetanov
Telerik team
 answered on 30 Oct 2018
1 answer
91 views

Hi

I have a RadGrid with AllowPaging = "True" and PageSize="20", On the OnItemDataBound method I make some rows (e.Item) Display = false.

However the paging totals and the items per page are now incorrect. The totals do not take into account the fact that some rows are now invisible and the number of items per page which was 20 now does not have that amount because some are invisible.

My question is how do I achieve the correct total and how do I get 20 items or rows a page

Attila Antal
Telerik team
 answered on 29 Oct 2018
1 answer
2.0K+ views

I want to be able to conditionally disable selection of a row based on another column on that row.  For example, I don't want to allow the user to select a row if a certain column is null.

I know how to conditionally set row and column attributes on data bound so think it's probably here but not sure what's next

function dataBound(e) {
    var rows = e.sender.tbody.children();
 
    for (var j = 0; j < rows.length; j++) {
        var row = $(rows[j]);
        var dataItem = e.sender.dataItem(row);
 
        // Disable the checkbox if the location isn't set
        if (dataItem.get("Location") === "") {
            row.css('background-color', '#FFFFCF');
            // What goes here?
        }
    }
 
    items = null;
}

 

I also tried to do this on the change event, which kind of work, but the selected IDs (selectedKeyNames) were still being set when the select all checkbox was clicked.

function onChange(e) {
 
    var i = e.sender.select();
    var grid = e.sender;
 
    i.each(function (i, e) {
        var dataItem = grid.dataItem(e);
        if (dataItem.get("Location") !== "") {
            $(e).removeClass("k-state-selected");
        }
    });
 
    items = this.selectedKeyNames();
 
}

 

 

Konstantin Dikov
Telerik team
 answered on 29 Oct 2018
1 answer
665 views

Hi, 

My grid has a column called Merchant which is supposed to turn into a dropdown list on edit.

For some reason, The initial  selected value doesn't connect to the column- does not appear as selected. And when I save on update- The value of the merchant doesn't get the changes on server side- it stays with initial value!!!.

This is the grid:

            @(Html.Kendo().Grid<DefaultLimitViewModel>
            ()
            .Name("DefaultLimitsGrid")           
            .Columns(columns =>
            {
                 columns.Bound(o => o.Id).Hidden();
                columns.Bound(o => o.DateLimitId).Hidden();
                columns.Bound(o => o.Merchant.MerchantName).EditorTemplateName("MerchantEditor").Title("Merchant").Width(150);
                columns.Bound(o => o.Rail).EditorTemplateName("RailEditor").Title("Rail").Width(150);
                columns.Bound(o => o.DefaultAmount).Format("{0:c}");
                columns.Command(command => { command.Edit().CancelText(" ").UpdateText(" ").Text(" "); command.Destroy().Text(" "); }).Width(200);


            })
            .ToolBar(toolBar => toolBar.Create())
            .Sortable()
            .Pageable(x => { x.AlwaysVisible(false); })
            .Scrollable()
            .Editable(editable => editable.Mode(GridEditMode.InLine))         
            .HtmlAttributes(new { style = "height:600px;" })
            .DataSource(dataSource => dataSource
            .Ajax()
            .PageSize(8)
            .Read(read => read.Action("Get_LimitsDefaultData", "Limits"))
            .Update(update => update.Action("UpdateDefaultLimit", "Limits"))
            .Destroy(Delete => Delete.Action("DeleteDefaultLimit", "Limits"))
            .Create(Create => Create.Action("CreateNewDefaultLimit", "Limits"))
            .Model(
            model =>
            {
                model.Id(item => item.DateLimitId);
             
            })

            )      
            )
       

 

 

This is the MerchantEditor

@(Html.Kendo().DropDownList()
                    .Name("Merchant")
                    .DataValueField("MerchantId")
                    .DataTextField("MerchantName")
             .DataSource(d => d.Read("Merchants_Read", "Limits")))
   

this is the Merchans_Read function:

 public IActionResult Merchants_Read()
        {
           
            using (var db = Db.Open())
            {
                var merchants = db.Select<Merchant>().OrderBy(x => x.Name).Select(mm => new MerchantModel { MerchantId = mm.Id, MerchantName = mm.Name }).ToList();

                return Json(merchants);
            }

        }

 

 

 

Viktor Tachev
Telerik team
 answered on 29 Oct 2018
3 answers
130 views

Telerik UI for ASP.NET MVC

I have wrongly assumed that the ListBox would work the same or similar to the grid.

I have created and populated a ListBox

cshtml..

@(Html.Kendo().ListBox()
        .Name(componentName: "lstRewindRolls")
        .Selectable(ListBoxSelectable.Single)
        .HtmlAttributes(new { tabindex = -1, @class = "k-listbox", style = "background-color:black; color:white; height:450px" })
        .DataValueField("DoffID")
        .DataTextField("RollID")
        .DataSource(dataSource => dataSource
            .Read(read => read.Action(actionName: "GetRolls", controllerName: "Rewind").Data("{ DispositionCode: 'R' }"))
        )
        .Events(events=>  events.Change("RewindRollSelected"))
)

 

controller...

public JsonResult GetRolls(string DispositionCode)
{
    try
    {
        var result = db.tblRolls.Where(r => r.strDispositionCode == DispositionCode && r.dtmInventoryRemoved == null)
            .Join(db.tblProductSKUs, p => p.lngProductSKUID, q => q.lngProductSKUID, (r, q) => new { r, q })
            .Join(db.tblProducts, s => s.q.lngProductID, t => t.lngProductID, (s, t) => new { s, t })
        .Select(o => new
        {
            DoffID = o.s.r.lngDoffID.ToString(),
            LaneID = o.s.r.strLaneID,
            RollID = o.s.r.lngDoffID.ToString() + o.s.r.strLaneID
        }).OrderBy(t => new { t.DoffID, t.LaneID }).ToList();
        ;
        return Json(result, JsonRequestBehavior.AllowGet);
    }
    catch (Exception ex)
    {
          ...
      }

 

When the page loads the ListBox is populated as expected.

Once I have processed an item in the list, if appropriate (the disposition changed) I want it removed from the list.

I thought I could simply do a dataSource.read()

var lstBox = $("#lstRewindRolls").data("kendoListBox");
lstBox.dataSource.read();

 

I also tried

var lstBox = $("#lstRewindRolls").data("kendoListBox");
lstBox.dataSource.read({ DispositionCode: 'R' });

 

I cannot seem to get it to work.

Please help.

 

Georgi
Telerik team
 answered on 26 Oct 2018
7 answers
445 views

I have an application that uses a model for the gantt. The model has a restriction of StringLength to 40 characters for the name of the task. However if the user edits a task in the grid and writes more than 40 characters no client validation is done and also the user does not see the failure of this.

Is there a example on how to implement client validations on gantt widget?

Dimitar
Telerik team
 answered on 26 Oct 2018
8 answers
2.8K+ views

Hi everyone,

I've got a ComboBox where I wanted to get tooltip on hover. I did it like the following:

@(Html.Kendo().ComboBoxFor(m => m)
          .Filter("contains")
          .Placeholder(ViewData.ModelMetadata.DisplayName)
          .DataTextField("Definition")
          .DataValueField("Code")
          .HtmlAttributes(new { style = "width: 100%", id = fieldname, title= "Some example"})
          .BindTo((System.Collections.IEnumerable)ViewData[bindto]))

When I hover the mouse on the ComboBox, it shows "Some example" but the real problem is where Kendo Validator message is also showing "Some example", before this I was getting like: This field is required. How can I fix this so it doesn't mix up the Title value with the required field message?

 

Thanks,

Alex

Jesper
Top achievements
Rank 1
 answered on 26 Oct 2018
10 answers
773 views
I have spent the night searching, and can't seem to find an answer for what must be a fairly common question.

I have a grid of 'Clients'. The client grids detail template is a grid of Licenses. Everything works fine, except when I add a row to the license grid, I can't  get access to the Client's Id column.

ViewModel
public class LicenseClient
{
    public int Id { get; set;  }
    public String Name { get; set; }
    public String Email { get; set; }
    public String City { get; set; }
    public int NumLicenses { get; set; }
}
 
public class LicenseInfo
{
    public int ClientId { get; set; }
    public Guid LicenseId { get; set; }
    public String Product { get; set; }
    public int Count { get; set; }
    public String Notes { get; set; }
}
My View:
@{
    ViewBag.Title = "Index";
}
 
<h2>Client Licenses</h2>
 
@(
    Html.Kendo().Grid<CoreLM.Models.ViewModels.LicenseClient>()
        .Name("clientGrid")
        .Columns( columns => {
            columns.Bound(c => c.Name);
            columns.Bound(c => c.City);
            columns.Bound(c => c.Email);
            columns.Bound(c => c.NumLicenses).Title("Total Licenses");
        })
        .DataSource(ds => ds.Ajax()
            .Read(r => r.Action("GetLicenseClients", "License"))
        )
        .Sortable()
        .Scrollable()
        .HtmlAttributes(new { style = "height:500px;" })
        .ClientDetailTemplateId("ClientLicenseDetailTemplate")
)
 
<script id="ClientLicenseDetailTemplate" type="text/kendo-tmpl" >
@(
 Html.Kendo().Grid<CoreLM.Models.ViewModels.LicenseInfo>()
        .Name("clientLicensesGrid_#=Id#")
        .Columns(columns =>
        {
            columns.Bound(c => c.Product);
            columns.Bound(c => c.Count).Title("Licenses");
            columns.Bound(c => c.Notes);
            columns.Command(c => c.Destroy());
            columns.Command(c => c.Edit());
        })
        .DataSource(ds => ds.Ajax()
            .Read(r => r.Action("GetLicensesForClient", "License", new { clientId = "#=Id#" }))
            .Create(c => c.Action("CreateLicenseForClient", "License", new { clientId = "#=Id#}))
            .Update(u => u.Action("ChangeLicensesForClient", "License"))
            .Destroy(d => d.Action("DeleteLicensesForClient", "License"))
            .Model(m => {
                m.Id(l => l.LicenseId);
            })
        )
        .ToolBar(tb => tb.Create())
        .Scrollable()
        .Sortable()
        .Editable()
        .ToClientTemplate()
)
</script>
My Controller method for creating a new license:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult CreateLicenseForClient([DataSourceRequest]DataSourceRequest request, int clientId, LicenseInfo li)
{
            //clientId is always 0
}

I have even tried hard coding an Id, and it still doesn't work:
.Create(c => c.Action("CreateLicenseForClient", "License", new { clientId = 99}))

and in my controller method, 'clientId' is still 0.

How can I pass the client (parent) id to the CreateLicenseForClient method? Without that id, I can't establish the Client has-many Licenses relationship.

Thanks,
~S
Kevin
Top achievements
Rank 1
 answered on 24 Oct 2018
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
Upload
ComboBox
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
MultiColumnComboBox
Dialog
DropDownTree
Checkbox
Slider
Switch
Notification
ListView (Mobile)
Pager
Accessibility
ColorPicker
DateRangePicker
Wizard
Security
Styling
Chat
MediaPlayer
TileLayout
DateInput
Drawer
SplitView
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Template
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
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?