Telerik Forums
UI for ASP.NET MVC Forum
1 answer
146 views
 Hello, I am unable to get data into my kendo grid. I have looked at many other threads but nothing has helped so far. I want to get the data from my controller / model but I am not sure if i am trying to do it correctly
 

 VIEW

@model MyProject.Models.POApprovalViewModel 
 
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}
 
@{
    ViewBag.Title = "PO Approval";
}
 
<div class="container">
    <h4>PO Approval</h4>     
 
    @(Html.Kendo().Grid(Model.AssignedApprovals)
              .Name("grdPOs")
              .Columns(columns =>
              {
                  columns.Bound(model => model.PoId);
                  columns.Bound(model => model.PoStatus);
              })
              .Pageable()
              .Sortable()
              .DataSource(dataSource => dataSource
                  .Ajax()
                  .ServerOperation(true)
                  .Model(model => model.Id("PoId"))
                  .Read(read => read.Action("POApproval_Read", "POApproval"))
               )
    )
 
</div>

 

 CONTROLLER

public class POApprovalController : Controller
{
    string UserId;
    POApprovalViewModel po;
 
    // GET: POApproval
    public ActionResult Index()
    {
        po = new POApprovalViewModel();
        return View(po);
    }
 
    [HttpPost]
    public ActionResult POApproval_Read()
    {
        dbPOApproval db = new dbPOApproval();
        return Json(db.GetAssignedApprovals());
    }
}

 

MODEL

    public class POApprovalViewModel
   {
       public List<OLAssignedApprovals> AssignedApprovals
       {
           get
           {
               if (_AssignedApprovals == null)
               {
                   _AssignedApprovals = new List<OLAssignedApprovals>();
               }
               return _AssignedApprovals;
           }
       }
 
       private List<OLAssignedApprovals> _AssignedApprovals;
   }   
 
   public class OLAssignedApprovals
   {
       public int PoId { get; set; }
       public string PoStatus { get; set; }
   }
 
   public class dbPOApproval
   {
       MyDataSourceOjbect objPOApproval = new MyDataSourceOjbect();
 
       public List<Models.OLAssignedApprovals> GetAssignedApprovals()       
       {
           List<Models.OLAssignedApprovals> lPoApproval = new List<Models.OLAssignedApprovals>();
           Models.OLAssignedApprovals li = new Models.OLAssignedApprovals();
 
           DataSet ds = objPOApproval.GetPOApprovals();
 
           foreach (DataRow dr in ds.Tables[0].Rows)
           {
               li = new Models.OLAssignedApprovals();
               li.PoId = Convert.ToInt32(dr["POID"]);
               li.PoStatus = dr["POStatus"].ToString();
 
               lPoApproval.Add(li);
           }
 
 
           return lPoApproval;
       }
   }

Dimiter Madjarov
Telerik team
 answered on 25 Nov 2015
1 answer
107 views

When the user clicks Update the cell in the grid isn't being populated with the EditorTemplate hyperlink value.

EditorTemplate:
@(Html.Kendo().Editor()
.Name("EVIDENCE")
.HtmlAttributes(new { style = "width: 250px;height:25px" })
.Tools(tools => tools.Clear().CreateLink())
.Value(@<text> </text>)
)

view:
<div class="wide-grid">
@Html.AntiForgeryToken()
@(Html.Kendo().Grid(Model.TASKs)
.Name("TasksGrid")
.Columns(columns =>
{
columns.Command(command => { command.Edit(); }).Width(50);
columns.Bound(c => c.STATUS).Visible(false);
columns.ForeignKey(c => c.RESP_ORG_ID, (System.Collections.IEnumerable)ViewData["RespOrgs"], dataFieldText: "RESP_ORG_DESC", dataFieldValue: "RESP_ORG_ID").Title("Resp Org").Width("200px");
columns.ForeignKey(c => c.ACTIVITY_ID, (System.Collections.IEnumerable)ViewData["Activities"], dataFieldText: "ACTIVITY_DESC", dataFieldValue: "ACTIVITY_ID").Title("Activity");
columns.ForeignKey(c => c.SOURCE_DOC_ID, (System.Collections.IEnumerable)ViewData["SourceDocs"], dataFieldText: "SOURCE_DOC_DESC", dataFieldValue: "SOURCE_DOC_ID").Title("Source Doc").ClientTemplate("<a href='#=SOURCE_DOC_PATH#'>#=SOURCE_DOC_DESC#</a>").Width(125);
columns.ForeignKey(c => c.ROLE_ID, (System.Collections.IEnumerable)ViewData["Roles"], dataFieldText: "ROLE_DESC", dataFieldValue: "ROLE_ID").Title("Role");
columns.Bound(c => c.RESP_ORG_ID).Visible(false);
columns.Bound(c => c.ACTIVITY_ID).Visible(false);
columns.Bound(c => c.ROLE_ID).Visible(false);
columns.Bound(c => c.DOC_REF).Width(75);
columns.Bound(c => c.DUE_DATE).EditorTemplateName("DueDate").Width(75);
columns.Bound(c => c.COMPLETED).Width(75);
columns.Bound(c => c.TASK_DESC).EditorTemplateName("TaskDescription").Width(500);
columns.Bound(c => c.EVIDENCE).EditorTemplateName("TaskEvidence").Width(15);
columns.Bound(c => c.CTL_NO);
columns.Bound(c => c.ACQUISITION_ID).Visible(false);
})
.ToolBar(toolbar => toolbar.Create().Text("Add New Task"))
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Pageable()
.Sortable()
.Filterable()
.Groupable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(15)
.ServerOperation(false)
.Events(events => events.RequestEnd("requestEnd"))
.Model(model =>
{
model.Id(a => a.TASK_ID);
})
.Update(update => update.Action("Edit", "Task").Data("sendAntiForgery"))
.Read(read => read.Action("TaskGrid_Read", "Task", new { id = @Model.ACQUISITION_ID }))
.Create(create => create.Action("Create", "Task").Data("sendAntiForgery"))
)
)
</div>

Dimiter Madjarov
Telerik team
 answered on 25 Nov 2015
2 answers
136 views

Hi,

in former WebForm projects I was using asp:DropDownList mostly in these kind of scenarios:

1) The DL was fully rendered server side and the selectable values have been populated using Object/SQL/LinqDataSource on the server.

2) The DL was two-way-bound (by the Bind or Eval statement) to a property of an arbitrary data model, e.g. in the context of a ListView or FormView.

To give you an example of the use case: Say a "status" property in a model need to have values like "On", "Off", "Unknown" and nothing else. An ObjectDataSource ensured, that the DL only contained the values for selection. Then the real model was queried in order to find the selected value and that was selected after Page_Load automatically. Once the user changed the selected value in the "status" DL, the new value was posted back to the server.

That worked fine.

I know how to achieve 1) in the "Kendo World", but I'm wondering, how I could simultaneously "two-way-bind" the DL to another model in order to set the "SelectedItem" form another data model as well as to POST finally changes made by the user.

Any pointer welcome

TIA

Neil
Top achievements
Rank 1
 answered on 24 Nov 2015
2 answers
130 views

I have a custom template for editing a scheduler event. In that template I have a grid to edit an array that is part of my model:

 @(Html.Kendo().Grid<Excent.Apps.Web.Solo.Models.MeetingStudentViewModel>(Model.Students)
                .Name("StudentsGrid")
                .Columns(columns =>
                {
                    columns.Bound(m => m.MeetingStudentID).Hidden();
                    columns.Bound(m => m.FullName).Title("Student");
                    columns.Bound(m => m.Goals);
                })
                .BindTo(Model.Students)
                .DataSource(dataSource => dataSource
                     .Ajax().ServerOperation(false)
                    .Model(model => model.Id(p => p.MeetingStudentID))
                     .Model(model => model.Field(o => o.FullName))
                     .Model(model => model.Field(o => o.Goals))
               )

When I display the template the grid is empty.

Zoran
Top achievements
Rank 1
 answered on 24 Nov 2015
4 answers
73 views

When I popup a recurrence event, it does not go back to the server where I have logic that is based on the start date before current date.

How do I manipulate the Model that it creates from a recurrence event so that I can hide things based on the start date in my custom template?

in my model I have isPassed but this is based on the first in the series and not the current event.. 

 

 

 

Zoran
Top achievements
Rank 1
 answered on 24 Nov 2015
4 answers
167 views

When my page containing a grid control in MVC 5 with Bootstrap is shrunk to below 1024 px. in width, the grid paging control gets distorted as shown in the attached screenshots.

I'm using a scaffolded MVC UI (2015.3.930) grid inside a default _layout body, i.e. it is being inserted inside a div with classes "container body-content" that have not been modified.

I am using customized bootstrap themes that I generated using the Bootstrap theme builder and the Kendo UI theme builder. To the best of my knowledge, I have only altered colors in the custom themes, not anything related to padding or sizing.

Anyone else seen this problems or have suggestions how to proceed or work around this behavior?

Iliana Dyankova
Telerik team
 answered on 24 Nov 2015
7 answers
196 views

Hi,

my treeview configuration at view:

@Html.Raw((Html.Kendo().TreeView().Name("AppellationTree").LoadOnDemand(true)
                .Events(events => events
                    .Select("TreeView_onSelect"))
                    .Template("# return escapeHtml(item.Name); #")
                .DataSource(d => d
                    .Model(m => m
                        .Id("Id")
                        .HasChildren("HasChildren")
                        .Children("Children")
                        .Field("IsAppellation", typeof(bool)))
                    .Read(r => r.Action("_AppellationTree", "Appellation", new { id = Model.Id })))
                .DataTextField("Name")))

My _AppellationTree method:

[ActionName("_AppellationTree")]
        public JsonResult GetAppellationData(int id)
        {
            var model = new List<TreeItemModel>();
            var appellations = _appellationRepo.GetList(x => x.ParentAppellation.Id == id).OrderBy(x => x.Name);
            foreach (var appellation in appellations)
            {
                var r = new TreeItemModel();
                r.Id = appellation.Id;
                r.Name = appellation.Name;
                r.HasChildren = appellation.HasChildren;
                model.Add(r);
            }

            return Json(model, JsonRequestBehavior.AllowGet);
        }

I'd like to add Expand Action with javascript function and launch loading data during expanding node. How to do it? I think that should possible out of the box with three js lines like:

function onExpand(e)

{

     get data (next level) from server

     attache data to existing data source

     fire expanding

}

Best regards

Bart

Boyan Dimitrov
Telerik team
 answered on 24 Nov 2015
9 answers
489 views

Hello 

Within my editor for a scheduler I'm changing some values through an AJAX-call and apparantely this does not change the model since the update action is never fired when I press update. The update works fine if I change a model bound value. How can I manually set the model as dirty?

Do I do it in the success method for the AJAX call and how?

Basically I just need to trigger update wheter the model is changed or not.

/Jonas

Vladimir Iliev
Telerik team
 answered on 24 Nov 2015
7 answers
117 views

I've noticed a problem with server filtering when the DropDownList is near the bottom of the page.  To reproduce the problem, go to http://demos.telerik.com/aspnet-mvc/dropdownlist/serverfiltering , and shrink the browser window so that the bottom of the browser comes up to to the bottom of the box around the products dropdown.  (See attached image for example.)

Click the products dropdown and notice the list is expanded above the control, which is good.

Now type "c", followed by "h". The list now moves below the control, off the page, and it can't be seen.  I haven't found a way to be able to see the products in the filtered list, because if I click the scrollbar to try to scroll down the control loses focus and selects the current item, and the same happens if I try to use my mouse's scroll wheel.  I am able to arrow down through the products, but it is still very awkward to not be able to see the list.

Also, this example is not a huge problem on this page, because the user could scroll the page down before entering the dropdown, and then be able to see all the contents.  But in my app several pages have DropDownLists at the very bottom of the page, which makes it impossible to ever see the filtered list.

I think a good fix for this would be that if the DropDownList starts off expanded above the control, to force it to stay displaying above the control while filtering is taking place.

Georgi Krustev
Telerik team
 answered on 24 Nov 2015
1 answer
121 views

Hi Telerik,

I'm using NumericTextBox in ASP.NET MVC now, and I don't see it support Mouse Wheel like control for ASP.NET AJAX?

Atanas Georgiev
Telerik team
 answered on 24 Nov 2015
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
Upload
ComboBox
MultiSelect
Window
ListView
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
Rating
ScrollView
ButtonGroup
CheckBoxGroup
Licensing
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?