This question is locked. New answers and comments are not allowed.
hello, i am stuck as i have the following EditTemplate for model caled MarijuanaMenuItem, when i click the edit button on the grid it opens the MarijuanaMenuItem.cshtml template i created just fin and every field that put with a @Html.TextBoxFor(s => s.<fieldName>) shows up fine .. the thing i have a couple dropdowns that i need to depend on data n one of the other fields, i have the @model at the top of the EditTemplate but when i inspect it the model s empty, so 2 questions 1) where is the data coming from if its not in my model? and 2) Can i access another fields data using whereever that is coming from ?
EditTemplate Code:
My Grid Code:
My Model:
EditTemplate Code:
@model my.potlocator.com_mvc_.Classes.MarijuanaMenuItem@using Telerik.Web.Mvc.UI@Html.ValidationSummary()<table><tr> <td> @Html.LabelFor(s => s.StrainType, "Strain Type") </td> <td> @(Html.Telerik().ComboBoxFor(s => s.StrainType) .Name("StrainType") .AutoFill(true) .DataBinding(binding => binding.Ajax().Select("GetStrainTypes", "Menu")) .Filterable(filtering => { filtering.FilterMode(AutoCompleteFilterMode.Contains); }) .HighlightFirstMatch(true) .ClientEvents(events => events .OnChange("onStrainTypeChange") //.OnLoad("onStrainTypeLoaded") ) ) @Html.ValidationMessage("MarijuanaMenuItem", "*") </td> <td> @Html.LabelFor(s => s.StrainName, "Strain Name") </td> <td> @(Html.Telerik().ComboBoxFor(s => s.StrainNameID) .Name("StrainName") .AutoFill(true) .DataBinding(binding => binding.Ajax().Select("GetStrains", "Menu")) .Filterable(filtering => { filtering.FilterMode(AutoCompleteFilterMode.Contains); }) .HighlightFirstMatch(true) .ClientEvents(events => events .OnDataBinding("onStrainNameDataBinding") //.OnLoad("onStrainNameLoaded") ) ) @Html.ValidationMessage("MarijuanaMenuItem", "*") </td></tr><tr> <td> @Html.LabelFor(s => s.description, "Description") </td> <td colspan="3"> @Html.TextBoxFor(s => s.description, new { style = "width:100%" }) </td></tr><tr> <td> @Html.LabelFor(s => s.halfgram, "1/2 Gram") </td> <td> @Html.Telerik().NumericTextBoxFor(s => s.halfgram) </td> <td> @Html.LabelFor(s => s.instock, "In-Stock?") </td> <td> @Html.CheckBoxFor(s => s.instock) </td></tr><tr> <td> @Html.LabelFor(s => s.gram, "Gram") </td> <td> @Html.Telerik().NumericTextBoxFor(s => s.gram) </td> <td> @Html.LabelFor(s => s.eighth, "1/8 Ounce") </td> <td> @Html.Telerik().NumericTextBoxFor(s => s.eighth) </td></tr><tr> <td> @Html.LabelFor(s => s.quarter, "1/4 Ounce") </td> <td> @Html.Telerik().NumericTextBoxFor(s => s.quarter) </td> <td> @Html.LabelFor(s => s.half, "1/2 Ounce") </td> <td> @Html.Telerik().NumericTextBoxFor(s => s.half) </td></tr><tr> <td> @Html.LabelFor(s => s.ounce, "Ounce") </td> <td> @Html.Telerik().NumericTextBoxFor(s => s.ounce) </td> <td> @Html.LabelFor(s => s.each, "Each") </td> <td> @Html.Telerik().NumericTextBoxFor(s => s.each) </td></tr><tr> <td> @Html.LabelFor(s => s.photo_url, "Menu Photo") </td> <td> @(Html.Telerik().Upload() .Name("file") .Multiple(false) .Async(async => async .Save("saveMenuPhoto", "Menu") // BROKEN! .Remove("deleteMenuPhoto","Menu") .AutoUpload(true) ) .ClientEvents(events => events .OnSuccess("menuUploadSuccess") .OnUpload("menuUpload") .OnSelect("checkUploadExtension") ) ) @Html.Hidden("menuphoto", "") </td> <td> @(Html.Telerik().DropDownList() .Name("Label") .DataBinding(binding => binding.Ajax().Select("getMenuLabels", "Menu")) ) </td></tr></table>My Grid Code:
@(Html.Telerik().Grid<MarijuanaMenuItem>() .HtmlAttributes(new { style = "font-size:small;" }) .Name("MarijuanaMenu") .DataKeys(keys => { keys.Add(p => p.menuid); }) .ToolBar(toolbar => toolbar.Insert().ButtonType(GridButtonType.ImageAndText)) .Columns(columns => { columns.Bound(o => o.photo_url) .Width(50) .Title("Photo") .ClientTemplate("<img height='50' width='50' src='http://my.potlocator.com/menu_uploads/<;#=photo_url #>' />"); columns.Bound(o => o.description).Title("Desc").Width(150); columns.Bound(o => o.StrainType).Title("Type").Width(100); columns.Bound(o => o.StrainName).Title("Name").Width(150); columns.Bound(o => o.StrainTypeID).Visible(true); columns.Bound(o => o.StrainNameID).Visible(true); columns.Bound(o => o.halfgram).Title("1/2g").Width(75); columns.Bound(o => o.gram).Title("g").Width(75); columns.Bound(o => o.eighth).Title("1/8").Width(75); columns.Bound(o => o.quarter).Title("1/4").Width(75); columns.Bound(o => o.half).Title("1/2").Width(75); columns.Bound(o => o.ounce).Title("oz").Width(75); columns.Bound(o => o.each).Title("ea").Width(75); columns.Bound(o => o.instock) .ClientTemplate("<input type='checkbox' disabled='disabled' name='instock' <#= 1 ? checked='checked' : '' #> />") .Title("In-Stock").Width(50); columns.Command(command => { command.Edit().ButtonType(GridButtonType.Image); command.Delete().ButtonType(GridButtonType.Image); }).Title("Actions").Width(50); }) .DataBinding(dataBinding => { dataBinding.Ajax() .Select("_getMenuAjax", "Menu", new { locationid = @Model.thisListing.ListingID }) .Update("_updateMenuAjax", "Menu") .Insert("_insertMenuAjax", "Menu", new { locationid = @Model.thisListing.ListingID }) .Delete("_deleteMenuAjax", "Menu"); }) .Pageable() .Editable(editing => { editing.Mode(GridEditMode.PopUp); editing.FormHtmlAttributes(new { enctype = "multipart/form-data" }); }) .Sortable() .Scrollable() .Groupable() .Filterable() )My Model:
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.ComponentModel;using System.ComponentModel.DataAnnotations;namespace my.potlocator.com_mvc_.Classes{ public class MarijuanaMenuItem { [ReadOnly(true)] public int menuid { get; set; } [ReadOnly(true)] public int locationid { get; set; } public string description { get; set; } [UIHint("StrainPhoto")] public string photo_url { get; set; } public int label_style { get; set; } [DataType(DataType.Currency)] public decimal halfgram { get; set; } [DataType(DataType.Currency)] public decimal gram { get; set; } [DataType(DataType.Currency)] public decimal eighth { get; set; } [DataType(DataType.Currency)] public decimal quarter { get; set; } [DataType(DataType.Currency)] public decimal half { get; set; } [DataType(DataType.Currency)] public decimal ounce { get; set; } [DataType(DataType.Currency)] public decimal each { get; set; } [DataType(DataType.DateTime)] public DateTime lastchanged { get; set; } public Boolean instock { get; set; } [UIHint("StrainName"), Required] public string StrainName { get; set; } [UIHint("StrainType"), Required] public string StrainType { get; set; } public int StrainNameID { get; set; } public int StrainTypeID { get; set; } }}