Telerik Forums
UI for ASP.NET MVC Forum
3 answers
209 views
How do I turn off editing and deletion of shapes in a diagram, but still allow them to be repositioned by dragging? I can turn off editing for shapes, connectors and the whole diagram, but then I can't move them.
Tsvetina
Telerik team
 answered on 19 Sep 2017
6 answers
730 views

Hi, i'm trying to render the value in class.

a.Bound(p => p.Username)
    .Title("User Picture")
    .ClientTemplate("<span>#=Username#</span><img src='" + CustomClass.GetPicture("#=Username#") + "'>");
 
#=UserUsername# not getting a value. But <span>#=Username#</span> working with rendered value (john.smith).
 
when i write name as string in class, it's working and i'm getting the user picture;
 
a.Bound(p => p.Username)
    .Title("User Picture")
    .ClientTemplate("<span>#=Username#</span><img src='" + CustomClass.GetPicture("john.smith") + "'>");

Thank You

Kemal
Top achievements
Rank 1
 answered on 19 Sep 2017
1 answer
1.2K+ views

Hello all, 

Package id: Telerik.UI.for.AspNet.Mvc5.Trial, version="2017.2.621", targetFramework="net461"

OS: Windows 7 Professional 

browser version: Google Chrome, Version 60.0.3112.113 (Official Build) (64-bit)

Environment: Visual Studio Professional 2017, Asp.Net mvc 5 

 

This is probably a simple question, but I can't seem to find an answer for it. In a nutshell, I would like to create a a Kendo UI grid in an Asp.net MVC 5 application that receives data from a WebApi without having any WebApi (server side) kendo code. 

For example, this is my current implementation (that works).

(1) I have an Asp.net Mvc 5 web application that has the client side code: 

Index.cshtml

    @(Html.Kendo().Grid<DataManager.Models.CommodityCodesViewModels.IndexViewModel>()
  .Name("grid")
  .Columns(columns =>
  {
      columns.Bound(c => c.CommodityCodeId);
      columns.Bound(c => c.CommodityCode).Width(100);
      columns.Bound(c => c.Description).Width(100);
      columns.Command(command => { command.Edit(); command.Destroy(); }).Width(172);
  })
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.InLine))
.HtmlAttributes(new { style = "height: 700px;" })
.Scrollable(s => s.Height(700))
.Groupable()
.Sortable()
.Pageable(pageable => pageable
    .Refresh(true)
    .PageSizes(true)
    .ButtonCount(5))
.Filterable()
        .DataSource(dataSource => dataSource
            .Ajax()
            .Model(m =>
            {
                m.Id(c => c.CommodityCodeId);
                m.Field(c => c.CommodityCodeId).Editable(false);
                m.Field(c => c.CommodityCode);
                m.Field(c => c.Description);
            })
    .Events(events => events.Error("error_handler"))
    .Create(create => create.Action("CommodityCodes_Add", "CommodityCodes"))
    .Read(read => read.Action("CommodityCodes_Read", "CommodityCodes"))
    .Update(update => update.Action("CommodityCodes_Edit", "CommodityCodes"))
    .Destroy(destroy => destroy.Action("CommodityCodes_Delete", "CommodityCodes"))
    )
    )

CommodityCodesController.cs

public class CommodityCodesController : Controller
{
    public CommodityCodesController()
    {
    }
 
    public ActionResult Index()
    {
        return View();
    }
 
     
    public async Task<ActionResult> CommodityCodes_Read( [DataSourceRequest] DataSourceRequest request, IndexViewModel model)
    {
        return Json(await new CommodityCodeHelpers().ApiGetAll(request, model) );
    }
 
    [HttpPost]
    public async Task<ActionResult> CommodityCodes_Add([DataSourceRequest] DataSourceRequest request, IndexViewModel model)
    {
        if (model != null && ModelState.IsValid)
        {
            HttpResponseMessage message = await new CommodityCodeHelpers().ApiPost(request, model);
        }
         
 
        return Json(new[] { model }.ToDataSourceResult(request, ModelState));
    }
 
    [HttpPost]
    public async Task<ActionResult> CommodityCodes_Edit([DataSourceRequest] DataSourceRequest request, IndexViewModel model)
    {
        if (model != null && ModelState.IsValid)
        {
            HttpResponseMessage message = await new CommodityCodeHelpers().ApiPut(request, model);
        }
        return Json(new[] { model }.ToDataSourceResult(request, ModelState));
    }
 
    [HttpPost]
    public async Task<ActionResult> CommodityCodes_Delete([DataSourceRequest] DataSourceRequest request, IndexViewModel model)
    {
        if (model != null && ModelState.IsValid)
        {
            HttpResponseMessage message = await new CommodityCodeHelpers().ApiDelete(request, model);
        }
        return Json(new[] { model }.ToDataSourceResult(request, ModelState));
    }
}

 

CommodityCodeHelpers.cs

public class CommodityCodeHelpers
{
    private string _uriBase = System.Configuration.ConfigurationManager.AppSettings.Get("CommodityCodesUriBase");
    private string _uriPath = System.Configuration.ConfigurationManager.AppSettings.Get("CommodityCodesUriPath");
 
    public async Task<DataSourceResult> ApiGetAll([DataSourceRequest] DataSourceRequest request, IndexViewModel model)
    {
        List<IndexViewModel> modelList = new List<IndexViewModel>();
 
        using (var client = new HttpClient()) // does this support socket reuse?
        {
            client.BaseAddress = new Uri(_uriBase);
            client.DefaultRequestHeaders.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            HttpResponseMessage Res = await client.GetAsync(_uriPath);
            if (Res.IsSuccessStatusCode)
            {
                //Storing the response details recieved from web api  
                var response = Res.Content.ReadAsStringAsync().Result;
                modelList = JsonConvert.DeserializeObject<List<IndexViewModel>>(response);
            }
 
            return modelList.ToDataSourceResult(request);
        }
    }
    public async Task<HttpResponseMessage> ApiPost([DataSourceRequest] DataSourceRequest request, IndexViewModel model)
    {
        using (var client = new HttpClient()) // does this support socket reuse?
        {
            client.BaseAddress = new Uri(_uriBase);
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            HttpResponseMessage response = await client.PostAsJsonAsync(_uriPath, model);
 
            if (response.IsSuccessStatusCode)
            {
                // maybe a redirect?
            }
 
            return response;
        }
    }
    public async Task<HttpResponseMessage> ApiPut([DataSourceRequest] DataSourceRequest request, IndexViewModel model)
    {
        using (var client = new HttpClient()) // does this support socket reuse?
        {
            client.BaseAddress = new Uri(_uriBase);
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            HttpResponseMessage response = await client.PutAsJsonAsync(_uriPath + "//" + model.CommodityCodeId, model);
 
            if (response.IsSuccessStatusCode)
            {
                // maybe a redirect?
            }
 
            return response;
        }
    }
 
    public async Task<HttpResponseMessage> ApiDelete([DataSourceRequest] DataSourceRequest request, IndexViewModel model)
    {
        using (var client = new HttpClient()) // does this support socket reuse?
        {
            client.BaseAddress = new Uri(_uriBase);
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            HttpResponseMessage response = await client.DeleteAsync(_uriPath + "//" + model.CommodityCodeId);
 
            if (response.IsSuccessStatusCode)
            {
                // maybe a redirect?
            }
 
            return response;
        }
    }
}

 

So, right now the grid is created in my Index view, and is handled in my MVC controller. My MVC controller builds an HttpClient and then consumes my WebApi, and everything works fine. 

Is there a way to use the Kendo().Grid HTML helper to consume the Web Api, while still using my Asp.net MVC controllers. Essentially, I would like to eliminate the need for me to build an Http Client to consume the Web Api, and instead have Kendo().Grid do it for me. 

 

Thanks for all the help!

RC

Stefan
Telerik team
 answered on 19 Sep 2017
1 answer
3.8K+ views
Is it possible to have a multiple lines in the header row for the column names?  I am migrating an existing HTML table to use the MVC grid (see attached).  I have tried placing a new line character ('\n') in the Title field but it does nothing.
Viktor Tachev
Telerik team
 answered on 18 Sep 2017
5 answers
712 views

Hello

I have a multiselect widget working in AutoBind mode. To speed up display, as long as the field is not changed, I would like to load the selected values using Autobind(false) and load the selected Items in .Value() as per the docs.

I have verified that Model.SelectedOwners contains the DataValues and Model.SelectedOwnersPreload contains a List of Items with Name / Id with the same DataValues.

If I set Autobind(true), the widget works as expected but is slow to read the full list of available items from the datasource. 

If I set Autobind(false) the widget works correctly on first load of the page. However, when the Form posts back and is rendered again, the selected Values are no longer shown, even though I render the page through the same code as on initial load and in the View, both the Value List (Model.SelectedOwners) and the Item List (Model.SelectedOwnersPreload) provide the expected Values.

What am I missing?

 

Currently the Code is:

@(Html.Kendo().MultiSelectFor(m => m.SelectedOwners)
                         .DataTextField("Name")
                         .DataValueField("Id")
                         .Placeholder(StringResource.SoftwareItemOwnersPlaceholder)
                         .AutoBind(true)
                         .DataSource(source =>
                         {
                             source.Read(read =>
                             {
                                 read.Action("GetAvailableOwners", "SoftwareItem");
                             });
 
                         }).Value( Model.SelectedOwnersPreload)
                   )

 

Regards,

Erwin

 

erwin
Top achievements
Rank 1
Veteran
Iron
 answered on 18 Sep 2017
1 answer
127 views

In Day View only the "Title" field is visible.  Without creating a custom view, is it possible to also make the "Description" field visible in Day View?

Thanks

Neli
Telerik team
 answered on 18 Sep 2017
1 answer
173 views

Hi 

I have got an issue where there is a 35px wide gap at the left hand side of all my line graphs.

Please see here for a demo

http://vsdash-test.azurewebsites.net/

I would like the line graph to display the full width of the blue area, and remove the blank space to the left.

When i expect the code, I am inside the markup used to create the SVG file.

Is there anyway I can remove this space at the left side?

Thank you for your time.

 

 

 

Stefan
Telerik team
 answered on 18 Sep 2017
2 answers
242 views
Is it possible to setup a different popup for use when editing records versus when adding new records?  When editing, there are certain fields we don;t want the user to edit, whereas when adding a new record, there are fields that do have to be set.  I was hoping I could set different templates for adding versus editing.  I suppose I could do it dynamically via javascript, but I was hoping there was a less intrusive method.
Joe
Top achievements
Rank 1
 answered on 15 Sep 2017
1 answer
217 views

I added a resource using the following code: 

 var scheduler = $("#scheduler").data("kendoScheduler");
            scheduler.resources[0].dataSource.add({
                Text: "aaaaaBBBBBB",
                Value: 23,
                Color: "#FFFFFF"
                
            });

scheduler.view(scheduler.view().name);

How can I get the resources to sort by Text so that it shows up in order and not at the end?

Dimitar
Telerik team
 answered on 15 Sep 2017
1 answer
407 views

I am using a Kendo MVC Scheduler control with a TimeLine view and I am adding new events via an ajax call to my server to add to a table that holds scheduler events.  I need a way to refresh the scheduler or to add an event manually just so it will show up until the next refresh.  Is there an easy way to do that?  

I tried the following but it doesn't call my read method:

var scheduler = $("#scheduler").data("kendoScheduler");

scheduler.resources[0].dataSource.read().then(
                function () {
                    scheduler.view(scheduler.view().name);
                });

This is my client side code:

 <% Html.Kendo().Scheduler<WheresMyTool.Models.MeetingViewModel>()
    .Name("scheduler")
    .Date(new DateTime(2016, 12, 16))
    .StartTime(new DateTime(2016, 12, 16, 7, 00, 00))
    .MajorTick(60)
    .EventTemplate(
                "<div class='#= eventStyle #' title='#= description #'>" +
                    "#= title #" +
                "</div>")
    .Views(views =>
    {
        views.TimelineWeekView(timeline =>
        {
            timeline.EventHeight(25);
            timeline.ColumnWidth(1);
        });
        views.TimelineView(timeline => 
        {
            timeline.EventHeight(25);
            timeline.ColumnWidth(10);
        });
        views.TimelineMonthView(timeline =>
        {
            timeline.StartTime(new DateTime(2016, 12, 16, 00, 00, 00));
            timeline.EndTime(new DateTime(2016, 12, 16, 00, 00, 00));
            timeline.MajorTick(1440);
            timeline.MinorTickCount(1);
            timeline.EventHeight(25);
            timeline.ColumnWidth(10);
        });
    })
    .Editable(a => a.Confirmation(false))
    .Timezone("Etc/UTC")
    .Group(group => group.Resources("Attendees").Orientation(SchedulerGroupOrientation.Vertical))
    .Events(e =>
    {
        e.DataBound("schedulerDataBound");
        e.Edit("scheduler_edit");
        e.Add("scheduler_add");
    })
    .Resources(resource =>
    {

        resource.Add(m => m.Attendees)
            .Title("Attendees")
            .Name("Attendees")
            .Multiple(true)
            .DataTextField("Text")
            .DataValueField("Value")
            .DataColorField("Color")
            .BindTo(Model.resourceList);
    })
    .DataSource(d => d
        .AutoSync(true)
        .Read("SchedulerRead", "Scheduler")
        .Create("SchedulerCreate", "Scheduler")
    ).Render();
        %>

Veselin Tsvetanov
Telerik team
 answered on 15 Sep 2017
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
DropDownButton
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
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
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?