Telerik Forums
UI for ASP.NET MVC Forum
3 answers
53 views

Hello

I have a grid displaying workitems and the last action taken for a workitem, recently I discovered that I need to extend this to include a history of actions stored in a separate table in the db.

the two tables looks like this:

workItem
id
name
lastActionDate
lastActionText

workAction
id
workItemID
actionDate
ActionText

My model currently looks like this:

public class workItemModel
    {
        public int id { get; set; }
        public string name{ get; set; }
        public DateTime lastActionDate{ get; set; }
        public string lastActionText{ get; set; }
    }

and my read action for the grid looks like this:

public ActionResult workItems_Read([DataSourceRequest]DataSourceRequest request)
        {
            return Json(GetWorkItems().ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
        }
 
        private static IEnumerable<workItemModel> GetWorkItems()
        {
            var wimDB = new wimDB_DEVEntities();
            return wimDB.workItem.Select(wiModel => new workItemModel
            {
                id = wiModel.id,
                name = wiModel.name,
                lastActionDate = wiModel.lastActionDate,
                lastActionText= wiModel.lastActionText
            });
        }
 

How do I extent my model and my read action to include the workAction table from the db?

/Jonas

Jonas
Top achievements
Rank 1
 answered on 08 Sep 2015
1 answer
99 views

Hi ,

   We are planning to switch the project from  Silverlight to MVC , So we need Telerik MVC supporting dlls .
Could you please tell me where I have to found those dlls  , I have downloaded UI for ASP.net MVC from Telerik site but I could not found any MVC dll’s  .
Can you please tell me from where I can get those dll’s .

 

Thanks

Victor

Sebastian
Telerik team
 answered on 08 Sep 2015
6 answers
2.2K+ views
Hello

I have a grid showing data (registrations) with the possibility to edit this data.
Each registration stores information about a region, stored in the DB as forgein key regionId for each registration.

When I edit a registration I want a dropdown for choosing region with the current region selected. The dropdown gets its values from the region table in the DB.
As I load the dropdown I think I loose the registration model and it gets replaced by the region model and thus I have no access to the regionId for the registration anymore, how can I get hold of the regionId value in the dropdown?

My editTemplate:
@model regDB.Models.registration
 
@Html.HiddenFor(model => model.id)
 
<div>
    @Html.EditorFor(model => model.regionId)
</div>
 
<div style="width: 250px;">
    @(Html.Kendo().DropDownList()
          .Name("Regions")
          .HtmlAttributes(new { style = "width: 250px" })
          .DataTextField("name")
          .DataValueField("id")
          .Value(model.regionId)
          .DataSource(source =>
          {
              source.Read(read =>
              {
                  read.Action("GetRegions", "Home");
              });
          })
    )
</div>
 and the GetRegions code:
public JsonResult GetRegions()
        {
            var regDB = new regDB_DEVEntities();
            regDB.Configuration.ProxyCreationEnabled = false;
            return Json(regDB.region, JsonRequestBehavior.AllowGet);
        }
If I remove the ProxyCreationEnabled, I'll get a circular reference error.

I hope you understand my question, otherwise i'll have to try to explain some more

/Jonas
Georgi Krustev
Telerik team
 answered on 08 Sep 2015
5 answers
114 views

Dear Telerik Community,

 I've recognized some weird behavior of the DatePickerWidget when switching from one month to another. You can take a look at the screen shot to see exactly what I'm talking about. I don't know if this already came up to somebody of you - I hope it did so someone can help me fix it.

 Kind regards,

Thomas

Iliana Dyankova
Telerik team
 answered on 07 Sep 2015
14 answers
131 views
Is there an beta/test UI for ASP.NET MVC for vNext (aka MVC 6)? Our team is starting to develop an .NET MVC 5 application, however, the concern is that by the time the product reaches a mature development stage, it will be immediately depreciated by MVC6.
T. Tsonev
Telerik team
 answered on 07 Sep 2015
1 answer
65 views

Hello,

I need to use my viewmodelpage in my read action of kendo mvc grid. This my codes :

#Controller

 VolViewModel model;

public ActionResult Index()
{
model = new VolViewModel { Item = new List<Vol>() };
model.Item = _volBusiness.GetAllVol();
return View(model);
}

[System.Web.Mvc.AcceptVerbs(HttpVerbs.Post)]
public ActionResult Read([DataSourceRequest]DataSourceRequest request)
{
var result = model.Item;
return Json(result.ToDataSourceResult(request));
}

 

#Index.cshtml

.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
.PageSize(15)
.Model(model =>
{
model.Id(m => m.VolId);
})
.Read(read => read.Action("Read", "Vol")
)

 

Thanks,

Viktor Tachev
Telerik team
 answered on 07 Sep 2015
1 answer
188 views

I have a Telerik MVC extension project that use CookieLocalizationModule to change language used in the application. It works fine and is setup in Web.Config as

        <httpModules>
            <add name="CookieLocalizationModule" type="OTP.Ring.Web.CookieLocalizationModule, OTP.Ring.Web" />
        </httpModules>

But after upgrade to Kendo, it is no longer working. So I want to know how to set CookieLocalizationModule in Kendo. Thanks.

Kiril Nikolov
Telerik team
 answered on 07 Sep 2015
1 answer
928 views

How can I bind the click event after the deferred script is loaded?

I have a Kendo Grid (in Razor) with deferred initialization due performance issues. So all js scripts are included in the end of the document.

@(Html.Kendo().Grid<MyViewModel>()
    .Name("myGrid")
    .Columns(columns =>
    {
        columns.Bound(c => c.Name);
        columns.Bound(c => c.City);
        columns
            .Bound(c => c.Id)
            .Title("Commands")
            .Sortable(false)
            .Filterable(false)
            .ClientTemplate(
                "<a href='" + @Url.Action("Details", new { id = "#=Id#" }) +
                    "' class='btn btn-success' title='Details'>" +
                    "<span class='glyphicon glyphicon-list'></span></a>" +
                "<a href='" + @Url.Action("Edit", new { id = "#=Id#" }) +
                    "' class='btn btn-info' title='Edit'>" +
                    "<span class='glyphicon glyphicon-pencil'></span></a>" +
                "<a href='\\#' data-id='#=Id#' data-action='deactivate' " +
                    "class='btn btn-warning' title='Desactivate'>" +
                    "<span class='glyphicon glyphicon-remove-sign'></span></a>"
            );
    })
    .Pageable()
    .Sortable()
    .Filterable()
    .DataSource(ds => ds
        .Ajax()
        .Read(read => read.Action("ReadData", "MyController")).Sort(a => a.Add("Name")))
    .Deferred()
)

 

Then I have a section at the end where I want to bind a click event to the <a> click of every element which a data-action='deactivate' attribute. The problem is the deffered initialization is performed after my document is ready.

 

@section scripts {
    @Scripts.Render("~/bundles/kendo")
 
    @Html.Kendo().DeferredScripts()
 
    <script>
        $(document).ready(function () {
            $('[data-action="deactivate"]').click(function (event) {
                var id = $(event.target).attr('data-id');
                alert(id);
            });
        });
    </script>
}

Boyan Dimitrov
Telerik team
 answered on 04 Sep 2015
2 answers
159 views

Hello, 

i have a grid with the column template with checkboxes, and chekbox to select all rows;

in the grid  i have enabled copy (.AllowCopy (true)), and it works if I select by clicking the ​rows and not the checkbox, however, if for example I select all lines using checkbox, the copy is not working.

I assumed might be a problem of focus, click on the checkboxes instead of rows, you lose the data to be copied, I have tried in the javascript selection function to shift the focus on the tbody of the grid, but this does not work ...

Any suggestions?

 Thanks, Roberto

Roberto
Top achievements
Rank 1
 answered on 04 Sep 2015
6 answers
1.1K+ views

I have a grid in a partial view and it's data source fails to call the read method on the initial page load.  It does get called when I submit the ajax form, but the problem is that I want some default data to appear in the grid when the page initially loads.

Also, if I take out the model as a parameter on the read method, then the read method will in fact get called during the initial page load, but the problem with that is then I won't be able to feed it any parameters to filter the data from the ajax form.

 I tried to call the read method from javascript in document.ready() to try and force it to call the read method, but that didn't work.  Is there a way I can make the read method get called in the initial page load while also feeding it the model as a parameter?

 

Here is the partial view called _ProjectResults

@model MvcTestProject.Models.ProjectSearchModel
 
@(Html.Kendo().Grid<MvcTestProject.Models.ProjectItem>()
        .Name("projectresultsgrid")
        .Columns(columns =>
        {
            columns.Bound(p => p.KeyID).Title("Key ID").Width(130);
            columns.Bound(p => p.StoreNumber).Title("Store").Width(130);
            columns.Bound(p => p.ProjectType).Title("Type").Width(150);
            columns.Bound(p => p.ProjectStatus).Title("Status").Width(130);
            columns.Bound(p => p.InstallStartDate).Title("Start Date").Width(130).Format("{0:MM/dd/yyyy}");
 
        })
        .Pageable()
        .Sortable()
        .Scrollable(scr => scr.Height(550))
        .Filterable()
        .DataSource(dataSource => dataSource
            .Ajax()           
            .PageSize(50)
            .ServerOperation(false)
            .Read(data => data.Action("ReadProjects", "Project", Model))
             
         )
)

 

Here is the parent page

@model MvcTestProject.Models.ProjectSearchModel
 
@{
    Layout = "~/Views/Shared/_Layout_Project.cshtml";
    ViewBag.Title = "Index";
}
 
<h2>Project Search</h2>
<div>
    @using (Ajax.BeginForm(new AjaxOptions { UpdateTargetId = "dvProjectResults" }))
    {
 
        <fieldset style="margin:10px;">
            <legend style="margin:5px;font-weight:bold">
                Search Criteria
            </legend>
            <table>
                <tr>
                    <td>@Html.LabelFor(m => Model.ProjectTypeID)</td>
                    <td width="400px;">
                        @(Html.Kendo().DropDownListFor(m => m.ProjectTypeID)
                          .HtmlAttributes(new { style = "width: 250px" })
                          .DataTextField("TypeName")
                          .DataValueField("ProjTypeID")
                          .BindTo(Model.ProjectTypeOptions)
                         .OptionLabel(" ")
                        )
                    </td>
                </tr>
                <tr>
                    <td>@Html.LabelFor(m => Model.ProjectStatusID)</td>
                    <td>
                        @(Html.Kendo().DropDownListFor(m => m.ProjectStatusID)
                          .HtmlAttributes(new { style = "width: 250px" })
                            .DataTextField("StatusName")
                            .DataValueField("ProjStatusID")
                            .BindTo(Model.ProjectStatusOptions)
                            .OptionLabel(" ")
                        )
                    </td>
                    <td>@Html.LabelFor(m => Model.StartDate)</td>
                    <td>@Html.EditorFor(m => Model.StartDate)</td>
                </tr>
 
                <tr>
                    <td>@Html.LabelFor(m => Model.KeyID)</td>
                    <td>@Html.EditorFor(m => Model.KeyID)</td>
                    <td>@Html.LabelFor(m => Model.EndDate)</td>
                    <td>@Html.EditorFor(m => Model.EndDate)</td>
                </tr>
                <tr>
                    <td>@Html.LabelFor(m => Model.StoreNumber)</td>
                    <td>@Html.EditorFor(m => Model.StoreNumber)</td>
                </tr>
                <tr>
                    <td colspan="2"><input type="submit" value="Search" /></td>
                </tr>
            </table>
 
        </fieldset>
 
 
    }
 
    <div id="dvProjectResults" style="margin:10px;">
        @{Html.RenderPartial("_ProjectResults", Model);}    
    </div>
</div>
 
<script type="text/javascript">
    $(document).ready(function () { JSReadProjects(); });
    function JSReadProjects() {
        var grid = $("#projectresultsgrid").data("kendoGrid");
        grid.dataSource.read();
    }
 
</script>

 Here is the http post actionresult that is executed when the ajax form is submitted:

[HttpPost]
public ActionResult ProjectSearch(ProjectSearchModel model)
{
    return PartialView("_ProjectResults", model);
}

Here is the read method on the controller:

public ActionResult ReadProjects([DataSourceRequest] DataSourceRequest request, ProjectSearchModel searchModel)
{
    var data = datamgr.GetProjects
        (
            searchModel.KeyID,
    searchModel.StoreNumber,
            searchModel.ProjectTypeID,
            searchModel.ProjectStatusID,
            searchModel.StartDate,
        );
 
    var serializer = new JavaScriptSerializer();
    var result = new ContentResult();
    serializer.MaxJsonLength = Int32.MaxValue; // Whatever max length you want here
    result.Content = serializer.Serialize(data.ToDataSourceResult(request));
    result.ContentType = "application/json";
    return result;
}

 

Daniel
Telerik team
 answered on 04 Sep 2015
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
Rating
ScrollView
ButtonGroup
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
DateTimePicker
AppBar
BottomNavigation
Card
FloatingActionButton
Licensing
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
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?