Telerik Forums
UI for ASP.NET MVC Forum
0 answers
136 views
I am developing my ASp.net MVC application using Kendoui MVC extensions. So In my form I have all the kendoui grid, dropdown, datepicker etc... I have accumulated them all in my @using(Html.BeginForm ()) But I am not sure How do i post my form data to the controller. If anybody has done that could you please shre your experience.

For example:

I have two entities: Faculty and FacultyType in My DAL

​public class Faculties
{
    public int FacultyId { get; set; }
    public string StaffNumber { get; set; }

    public int FacultyTypeId { get; set; }
    public virtual FacultyTypes FacultyTypes { get; set; }
}

public class FacultyTypes
{
    public FacultyTypes()
     {
       this.Faculties = new List<Faculties>();
      }
    public int FacultyTypeId { get; set; }
    public string FacultyTypeCode { get; set; }
    public string FacultyType { get; set; }
    public bool IsDefunct { get; set; }
    public virtual ICollection<Faculties> Faculties { get; set; }
}


I have my ViewModels in my application:

​public class ViewModelFaculty
{
    public int FacultyId { get; set; }
    public string StaffNumber { get; set; }

    public ViewModelFacultyTypes FacultyType { get; set; }
}

public class ViewModelFacultyTypes
{

    [ScaffoldColumn(false)]
    public int FacultyTypeId { get; set; }

    [Required(ErrorMessage ="Faculty Type Code is Required")]
    public string FacultyTypeCode { get; set; }

    [Required]
    public string FacultyType { get; set; }

     public bool IsDefunct { get; set; }

}

My View page having kendoui extensions for ASp.net MVC.

@using(Html.BeginForm())
{
<fieldset>
<legend class="main">Personal Particulars</legend>
<div class="view-table">
<div class="view-row">
<div class="view-name"><label for="staffId">Staff ID</label></div>
<div class="view-name"><input id ="txtStaffId" name="StaffId" class="k-textbox" data-bind="value: StaffId" type="text" required /></div>
<div class="view-name"><label for="facultyType">Faculty Type</label></div>
<div class="view-name">
@(Html.Kendo().DropDownList()
.Name("ddFacultyType")
.DataTextField("FacultyType")
.DataValueField("FacultyTypeId")
.OptionLabel("Select Faculty Type")
.Enable(true)
.AutoBind(true)
.DataSource(ds =>
{
ds.Read(read =>
{
read.Action("GetFacultyTypes", "NewFaculty");
})
.ServerFiltering(true);
})

)
</div>
</div>
}

I am showing a part of my view as if I could post two fields then rest all will be of same logic.
So now when I submit my form I need to post the data in the form to controller.
Even kendoUi website as also not given any end to end example of how to use the extensions in a form and how to post the data.

If anyone has been working in same enviorment or any direction on how to do please suggest me.

Steve
Top achievements
Rank 1
 asked on 11 Feb 2014
6 answers
367 views
We are trying the trial version to determine if we are going to purchase it but my testing has run into a problem. I am trying to load a data source in JavaScript so that will be called when a id from the treeview is passed on selection ( that part is working) , but when I call my java script function the data source creates but no data is returned, I have included my JavaScript function here and I have also included the method from the controller it is to call, can someone tell me why I get no data back, i have created an alert at the end of the function to show the data but the length is always zero for the loop does not execute

here is the JavaScript

    var updateAgencySystemInfo = function (agencyId, agencySystemModel) {
        var ds = new kendo.data.DataSource({
            trasnport: {
                read: {
                    type:"POST",
                    url: "/Administrator/GetAgencySystemInfo",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json"
                },
                parameterMap: function (options, operation) {
                    switch (operation) {
                        case "read":
                            return JSON.stringify(options);
                            break;
                        //case "destroy":
                        //    return JSON.stringify(options);
                        //    break;
                        //case "create":
                        //case "update":
                        //    return JSON.stringify(options);
                        //    break;
                    }
                }
            },
            schema: {
                model: {
                    id: "AgencySystemID", // the identifier of the model
                    fields: {
                        "AgencySystemID": { type: "number", editable: false },
                        "AgencyID": { type: "number", editable: false },
                        "Description": { type: "string" },
                        "DatabaseTypeID": { type: "number" },
                        "DataSource": { type: "string" },
                        "InitalCatalog": { type: "string" },
                        "UserID": { type: "string" },
                        "Password": { type: "string" },
                        "LastImportStartDateTime": { type: "date" },
                        "LastImportEndDateTime": { type: "date" },
                        "NextImportDateTime": { type: "date" },
                        "UpToDateTime": { type: "date" },
                        "ImportFrequency": { type: "number" },
                        "ImportFrequencyUnitID": { type: "number" },
                        "MaxImportWindow": { type: "number" },
                        "IsActive": { type: "boolean" }
                    }
                }
            }
        });
        ds.read({ Id: agencyId });
        
        ds.fetch();
        var datasourcedata = ds.data();
        
        for (var i = 0; i < datasourcedata.length; i++) {
            var dataitem = datasourcedata[i].Description;
            alert(dataitem);
        }



        return datasourcedata.length;
    };


Now here is the method from the controller the datasource is to call for the data.

        [HttpPost]
        public JsonResult GetAgencySystemInfo(long? agencyID)
        {
            var agencySystemInfo = (from p in dc.mst_AgencySystem where p.AgencyID == agencyID select p).ToList();

            return Json(agencySystemInfo, JsonRequestBehavior.AllowGet);

        }


Thanks,
rglunt68
Roy
Top achievements
Rank 1
 answered on 10 Feb 2014
1 answer
160 views
Hi,

I've posted a question to this topic a year ago and the solution went fine. Today I updated to the newest version of Kendo UI and now I have problems with the code. Looks like the update broke things for me.

The original question was, how to bind data in a clientdata from the parent row. The solution worked by using the DetailInit Method of the Parent Grid to set the data in the datasource of the Childgrid.
http://www.telerik.com/forums/grid-bind-a-clientdetailtemplate-to-a-collection-in-parent-row

My Parent Grid looks like this:
01.@(Html.Kendo().Grid<Models.AgentCommissionDetail>()
02..Name("commissionGrid")
03.        .Columns(
04.            col =>
05.            {
06.                    // cols..
07.            })
08.            .ClientDetailTemplateId("detailTemplate")
09.        .DataSource(dataSource => dataSource
10.       .Ajax()
11.       .ServerOperation(false)
12.    )
13.    .Events(events => events.DetailInit("initDetail"))
14.    .BindTo(Model.GroupedDetails)


Child Template:
01.@(Html.Kendo().Grid<Models.AgentCommissionDetail>()
02.        .Name("details_#=CustomerNr#")
03.        .Columns(col =>
04.        {
05.        // cols
06.        })
07.        .DataSource(dataSource => dataSource
08.            .Ajax()
09.            .ServerOperation(false)
10.           .Sort(p => { p.Add(x => x.ArticleGroup); p.Add(x => x.DiscountGroup); p.Add(x => x.ProductGroup); p.Add(x => x.Revenue).Descending(); })
11.        )
12.        .Pageable()
13.        .Sortable()
14.        .ToClientTemplate()
15.)

And finally the DetailInit to wire it together:
1.function initDetail(e) {
2.    var grid = $("#details_" + e.data.CustomerNr).data("kendoGrid");
3.    grid.dataSource.data(e.data.Details);
4.}

As I said, everything worked fine in the last years version. 

Following steps happen:
 - I expand a row
 - My data is shown as usual
 - But now, an post server request is made to my controller action. That's pretty strange, because I didn't specify any read methods in my datasource.
 - Since no data is returned from the controller, the grid will be empty as soon as the request is finished.

If I comment out the DataSource specification of the Childgrid, no request is made. But then my data is not sortedand Server Paging is enabled. Due to this, I tried to create a new datasource in the initDetail JS-Function, which has the specified sort-definition and turned off server paging. But I'm unable to set the Grid's datasource (already searched in the forums).

Was there a breaking change?

Thanks for any advices.

Greets


Petur Subev
Telerik team
 answered on 10 Feb 2014
1 answer
267 views
I am having trouble determining how to setup a TabStrip to load a tab's content from a json controller action and bind it to a kendo template; especially since @(Html.Kendo().DataSource()) and @(Html.Kendo().TabStrip().DataSource()) seem to be M.I.A.

Therefore, would it be possible to get an updated version of the ajax.cshtml demo on http://demos.telerik.com/kendo-ui/web/tabstrip/ajax.html that demonstrates how to obtain the json data and bind the data to a kendo template rather than having the data hard-coded within the ajaxContent1.html, ajaxContent2.html, and ajaxContent3.html files?
Alexander Popov
Telerik team
 answered on 10 Feb 2014
1 answer
673 views
I've been trying to figure out how to save and recover the column order as set by the user. Does anyone have any working example code on how they've managed to accomplish this? I've found examples of saving filter, sort and page info I've also figure out how to save column viability information but haven't found any information regarding saving user defined column order.

Any help would be appreciated.
Dimiter Madjarov
Telerik team
 answered on 10 Feb 2014
2 answers
223 views
Hello,

Can you give me a complete example for dropdownlist in the editortemplates?

For now I have to change all my dropdownlist in every views like this and I Wonder if it's possible to define a generic way in EditorTemplates?

@(Html.Kendo().DropDownList()
    .Name("NoRisque") // Name of the widget should be the same as the name of the property
    .DataValueField("Value") // The value of the dropdown is taken from the EmployeeID property
    .DataTextField("Text") // The text of the items is taken from the EmployeeName property
    .BindTo((SelectList)ViewBag.NoSource) // A list of all employees which is populated in the controller
)
Louis
Top achievements
Rank 1
Iron
Iron
Iron
 answered on 07 Feb 2014
4 answers
288 views
Hello,

I have a Visual Studio 2012 Telerik MVC 4 Web Application (Razor) Project and I cannot see the rad controls when I have a cshtml page selected. If I add in an aspx view I can see them for it. Can someone please let me know how to fix the toolbox so I can drag and drop rad controls onto my cshtml pages or if it is possible to do at all?
Dominick
Top achievements
Rank 1
 answered on 07 Feb 2014
5 answers
458 views
New to Kendo UI as well as MVC/Entity Framework, so please pardon me if this is a silly question.
I've spent the last 3 days trying to populate a DropDownList from a table within a SQL database.  Doing a basic BindTo(Model), I was getting a JSON circular reference error.  I eventually found the AJAX binding help page (http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/dropdownlist/overview#configure-the-kendo-dropdownlist-for-ajax-binding) and tried giving that a shot.
I modified it a bit to create a new Json result to contain only the table colums I need and eliminate the circular reference.  My application now builds and runs through, but I either get an empty dropdownlist or a spinning/loading image within the dropdownlist.  I put a break in the code, and I can see the 'results' array contains the correct information from the database table.  What am I doing wrong?

Controller:
namespace KendoUIMvcApplication1.Controllers
{
    public class HomeController : Controller
    {
        pinnwebEntities2 _db = new pinnwebEntities2();

        public ActionResult Index()
        {
            
            ViewBag.Message = "Welcome to ASP.NET MVC!";
            return View();
        }
        public JsonResult GetOUs()
        {
            var results = Json(from obj in _db.OUs select new { OU1 = obj.OU1, OU_description = obj.OU_description });
            
            return Json(results, JsonRequestBehavior.AllowGet);
        }

Index.cshtml:
@{
    ViewBag.Title = "Home Page";
}

@(Html.Kendo().DropDownList()
           .Name("clients")
           .DataTextField("OU_description")
           .DataValueField("OU1")
           .DataSource(source =>
            {
                source.Read(read =>
                    {
                        read.Action("GetOUs", "Home"); //Set the Action and Controller name
                    });
            })
           .SelectedIndex(0)
          )
Dimiter Madjarov
Telerik team
 answered on 07 Feb 2014
1 answer
148 views
Hello,

I'm trying to get the baseunitstep to only be used while showing days, and or if the days exceed more then 100 or if you get to many charts to fit, is this possible with the razor extension?

Thanks in advance
Iliana Dyankova
Telerik team
 answered on 07 Feb 2014
5 answers
119 views
I am wanting to replace MVCContrib grid with the Telerik grid in our projects.  With the Telerik grid can we define columns as a class like in MVCContrib e.g. Html.Grid(listOfData).WithModel(new ItemGridDef()) ?  

This allows us to reuse the grid in our project.
Alexander Popov
Telerik team
 answered on 07 Feb 2014
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
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?