Here i am using razor view
<div class="editor-label">
@Html.LabelFor(model => model.ob_guid,"Im Objekt")
</div>
<div class="editor-field">
@(Html.Kendo().ComboBoxFor(model=>model.ob_guid)
.Name("categories")
.HtmlAttributes(new { style = "width:300px",id="categories" })
.Placeholder("Select category...")
.DataTextField("CategoryName")
.DataValueField("CategoryId")
.Filter(FilterType.Contains)
.DataSource(source =>
{
source.Read(read =>
{
read . Action ( "GetCascadeCategories" , "Limitations" );
});
})
)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.von,"Code")
</div>
<div class="editor-field">
<input type="text" name="target" id="target" />
</div>
<script>
$(document).ready(function () {
$("#categories").change(function () {
var url = '@Url.Content("~/")' + "Limitations/ThanaByDistrict_SelectedState";
var ddlsource = "#categories";
var ddltarget = "#target";
$.getJSON(url, { Sel_StateName: $(ddlsource).val() }, function (data) {
$(ddltarget).empty();
$(ddltarget).val(data);
});
});
});
</script>
In my controller
// Get object Combox vale
public JsonResult GetCascadeCategories ( )
{
return Json ( db . objects . Select ( c => new { CategoryId = c . ob_guid , CategoryName = c . ob_name } ) , JsonRequestBehavior . AllowGet );
}
// Get selected combox value
public JsonResult ThanaByDistrict_SelectedState ( Guid Sel_StateName )
{
JsonResult result = new JsonResult ( );
objects temp=db . objects . Single ( m => m . ob_guid == Sel_StateName );
result . Data = temp.ob_code;
result . JsonRequestBehavior = JsonRequestBehavior . AllowGet;
return result;
}
Comments
Post a Comment