Telerik Forums
UI for ASP.NET MVC Forum
5 answers
341 views
I've got a grid which is bound via AJAX binding, with a pop-up edit form based upon an editortemplate. The form will only allow certain fields to be updated, and the controller takes this into account.

I've encountered several issues
  1. I can't display some fields as text (for informational purposes) using the html helper DisplayTextFor - integer fields just display 0, and text fields show nothing. However, these fields display ok, when using the TextBoxFor helper (which I don't want!)
  2. When using the Kendo dropdown list, I can get it display the list of values, but it won't display the current value in the edit form - just the first value in the list. I've had to go back to using the standard DropDownListFor helper, which works.
@(Html.Kendo().DropDownListFor(c=>c.HRFlag)
         .Name("HRList")
         .DataTextField("DisplayText")
       .HtmlAttributes(new { value = Model.HRFlag })
         .DataValueField("KeyValue")
         .DataSource(source=>source   
       .Read(read=>read.Action("GetEditHRStatusList", "HR"))))

3. When the update is made, the grid isn't being refreshed to display the correct data - sometimes no changes are shown, and sometimes two records are shown duplicated.  I've checked the update controller method, and the updated data is being passed back OK.

Controller:-
[AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Update([DataSourceRequest] DataSourceRequest request, Models.sysVacancies proposal)
        {
            Models.EVASdBDataContext db = new Models.EVASdBDataContext();
 
            Models.Vacancy originalProposal = (from v in db.Vacancies
                                              where v.ID==proposal.ID
                                              select v).Single();
 
            originalProposal.HRFlag = proposal.HRFlag;
            originalProposal.HRVacancyRef = proposal.HRVacancyRef;
 
            db.SubmitChanges();
            var query = from v in db.sysVacancies
                        where v.FinalReview != null & v.VacancyAuthorisation == "Y"
                        select v;
 
            query = query.OrderByDescending(c => c.SubmissionDate);
 
            return Json(query.ToDataSourceResult(request, ModelState));
 
        }

Grid definition:-
@(Html.Kendo().Grid<EVAS_MVC.Models.sysVacancies>()
.Name("Grid")
.Events(e=>e.Edit("onEdit"))
.Columns(columns=>
    {
        columns.Bound(p => p.ID).Title("").ClientTemplate("<img src='" + @Url.Content("~/Content/") + "#: HRGif #' alt='Proposal Details'").Filterable(false).Sortable(false);
    columns.Bound(p=>p.ID);
    columns.Bound(p => p.SubmissionDate).Title("Submission Date").Format("{0:d}");
    columns.Bound(p => p.PostTitle);
    columns.Bound(p=>p.SubmittingUser).Filterable(false);
    columns.Bound(p => p.DirectorateName).Title("Directorate").Filterable(false);
    columns.Bound(p => p.DGMName).Title("Manager").Filterable(false);
    columns.Bound(p => p.NoOfPosts).Title("Posts").Filterable(false);
    columns.Bound(p => p.WTE).Title("WTE").Filterable(false);
    columns.Bound(p => p.PayScaleDesc).Title("Pay Scale").Filterable(false);
    columns.Bound(p => p.Grade).Title("Grade").Filterable(false);
    columns.Bound(p => p.SmartCard).Title("Smart Card?").Filterable(false);
    columns.Bound(p => p.ID).Title("").ClientTemplate("<a href='http://ReportServer/ProposalDetails_Dev&id=#: ID #&rs:Command=Render&rs:Format=PDF'   target='_blank'><img src='" + @Url.Content("~/Content/Images/pdf.gif") + "' alt='Proposal Details'  style='border-width:0;Margin-left:5px;' /></a> <a href='http://getfile.aspx?DocID=#: JobDescID #'   target='_blank' style='#: JobDescStyle #'><img src='"  + @Url.Content("~/Content/Images/16-message-info.gif") + "' alt='Job Description'  style='border-width:0;Margin-left:5px;' /></a><a href='getfile.aspx?DocID=#: PersSpecID #'   target='_blank' style='#: PersSpecStyle #'><img src='" + @Url.Content("~/Content/Images/16-message-info.gif") + "' alt='Personal Specification'  style='border-width:0;Margin-left:5px;' /></a>  <input type='image' src=' " + @Url.Content("~/Content/Images/16-clock.gif") + "' onclick='showTimes(#: ID#);' style='border-width:0;Margin-left:5px;'/>").Filterable(false).Sortable(false);
    columns.Command(command =>
    {
        command.Edit().Text(" ");
     
    });
      
    })
    .ToolBar(c=>c.Template("<span style='Margin-right:10px;Margin-left:10px;'>Status:</span>" +
         
        Html.Kendo().DropDownList().Name("StatusList").DataTextField("DisplayText").DataValueField("KeyValue")
        .Events(e=>e.Change("onChange"))
        .HtmlAttributes(new { style="width:300px;"})
        .DataSource(source=>source   
             
        .Read(read=>read.Action("GetHRStatusList", "HR"))).ToHtmlString()
         
         
         
         
        ))
        .Editable(editable=>editable
        .Mode(GridEditMode.PopUp))
    .DataSource(dataSource=>dataSource
        .Ajax()
        .Model(m=>m.Id(p=>p.ID))
        .PageSize(20)
        .Read(read=>read.Action("HRVacanciesRead","HR"))
        .Update(update=>update.Action("Update","HR"))
        )
        .Pageable()
        .Sortable()
        .Filterable()
        )

I'm using the latest version of the  Kendo UI Complete for ASP.NET MVC (2012.2.831), which has solved the issue of null fields being shown as 'null'.
David A.
Top achievements
Rank 1
 answered on 08 Oct 2012
0 answers
158 views
If a grid row is selected by default when the grid is loading, and if that particular row is not visible in the page i.e. it is the last row of the grid so you have to scroll to see it.
Then after some operation in another page when the grid is reloaded i have a function that auto selects the previously selected row but since it is the last item you cant see it. Is there any way to auto scroll the grid to the selected row.
sri
Top achievements
Rank 1
 asked on 08 Oct 2012
4 answers
255 views
Hi,

I am using Visual Studio 2010 and MVC 4.
I am creating a new "Asp.NET MVC 4 Web Application".
Right click and "Kendo UI for Asp.NET MVC" \\ "Convert to Kendo UI for ASP.NET MVC Application" and project is preparing for me.
and I am inserting to index.cshtml "@(Html.Kendo().DatePicker().Name("Birthday"))" 
and I am running....
But style is curropted as it appears in the attached file.

Dimo
Telerik team
 answered on 08 Oct 2012
1 answer
269 views
Hello,

I am new to Kendo and also to MVC 3. I am trying to bind the grid with Dynamic datatable (It can have 20-25 columns based on the request). Currently I am using the autogenerate to bind the grid. but the problem what I am facing is, I am unable to set the width of each column also also horizantal scroll bar is not appering.

It would be great, if anyone could suggest me better approach to bind the datatable to grid otherthan what I am doing and also the solutions to my problem.

Thanks in advance.

Regards,
Ravi
Ravi
Top achievements
Rank 1
 answered on 08 Oct 2012
1 answer
152 views
Using the aggregates example, I am tryiing to create totals and counts on the header and footer templates in the detail templates. The "sum" or "count" template spacers are not recognized. It gives me a javscript error "sum" not recognized or "value" not recognized".  Can you point to an emxample or give me some idea about how to get aggregates int he detail templates
Jon
Top achievements
Rank 1
 answered on 04 Oct 2012
0 answers
129 views
I was looking at the team pulse demo and the time sheet has a weekly date picker and when you change the date you can see what has been put in for that week. I was wanting to make a time card web app that a user can sign in and enter the number of hours they worked per day so It would take the week they selected and update the view to display the correct dates for that week. I will include the screen shot but my question is how does this get wired up to where it knows the dates of that week? Also this is a MVC 4 app

Brent
Brent
Top achievements
Rank 1
 asked on 04 Oct 2012
0 answers
160 views
Hi,

I have a Kendo comboboxfor on my view and the datasource comes from my model as an IEnumerable<SelectListItem>.  But running the page crashes with the subject error message.  If I change the CombBoxFor to ComboBox and attach the datasource with the dataSource method, it seem to work.  What is wrong here: 

Here is my View (code is partial):
<li>
  @Html.LabelFor( m => m.FKStatusTypeId )
  @(Html.Kendo()
          .ComboBoxFor( m => m.FKStatusTypeId )
          .BindTo( Model.StatusTypeList)
  )
</li>

and here is my Model (code is partial):
[Display( Name = "Status" )]
public int FKStatusTypeId { get; set; }
 
// use as @Html.DropDownListFor(m => m.FKBillingTypeId, Model.BillingTypeList, "--select--")
//        @Html.ValidationMessageFor(m => m.FKBillingTypeId)
 
[Display( Name = "Zip Code" )]
[Required( ErrorMessage = "Zip Code is required" )]
[ZipCodeOnly( ErrorMessage = "Zip code is not valid" )]
[ValidateZipCode( ErrorMessage = "ZipCode is not valid" )]
public string Zip5 { get; set; }
 
public SelectList ZipCities { get; set; }
 
public IEnumerable<SelectListItem> StatusTypeList
{
   get
   {
     var ctx = new PCDataEFContext();
     var sTypes = ctx.StatusTypes;
     var items = sTypes.Where( st => st.PKId > 0 )
                   .ToList()
                   .Select( st => new SelectListItem
                         {
                           Text = st.Name,
                           Value = st.PKId.ToString()
                         } );
     return items;
   }
}

What am I doing wrong here?

Babu.



Babu
Top achievements
Rank 1
 asked on 04 Oct 2012
1 answer
95 views
Basically, I have a bulleted list inside the listview, and when a user selects and item, I want it to automatically fire the create action method. And when the user deselects I want it to fire the Destroy action method
Vladimir Iliev
Telerik team
 answered on 04 Oct 2012
0 answers
94 views
Hi,

I have noticed that the "Ends with" filter does not always work when the entry matches an item in the column. I'm using client side filtering and paging.

An example of this behavior can be seen by going to the  Grid /Binding to local data online sample at http://demos.kendoui.com/web/grid/local-data.html 

In the City column set the filter "Ends with" then enter New York in the text field, 17 records are returned 4 with New York as the city, 3 with Redmond as the city and 10 with Seattle as the city.

Is there a fix and/or workaround for this issue?

Thank you,
Eric
Eric Brunswick
Top achievements
Rank 1
 asked on 03 Oct 2012
0 answers
121 views

I am using mvc4. On one of my page, it has Kendo Grid. I want to show 5 rows per page. I have no problem doing it using pure javascript, however, If I am using mvc helper. I got lost, couldn't find any samples online.

here's my javascript code.




$(document).ready(function () {
$("#grid").kendoGrid({
dataSource: {
type: "json",
serverPaging: true,
pageSize: 5,
transport: { read: { url: "Products/GetAll", dataType: "json"} },
schema: { data: "Products", total: "TotalCount" }
},
height: 400,
pageable: true,
columns: [
{ field: "ProductId", title: "ProductId" },
{ field: "ProductType", title: "ProductType" },
{ field: "Name", title: "Name" },
{ field: "Created", title: "Created" }
],
dataBound: function () {
this.expandRow(this.tbody.find("tr.k-master-row").first());
}
});
});



now if i am using mvc helper

@(Html.Kendo().Grid(Model) 
.Name("Grid")  // please help me to finish this



John
Top achievements
Rank 1
 asked on 03 Oct 2012
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
MultiColumnComboBox
Dialog
DropDownTree
Checkbox
Slider
Switch
Notification
Accessibility
ListView (Mobile)
Pager
ColorPicker
DateRangePicker
Security
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
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
SegmentedControl
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?