Hi Friends,
I facing some issue while binding the data with kendo grid
Aim : I want to call different action methods on radio button (s) selection (not kendo radio buttons) selection , my controller action will fetch the data from DB and return through Json. and binding the kendo grid with the resulted data
Issue : controller action is not being invoked.on second radio button selection
below are my code bits
.cshtml
switch (TempData["redirect"].ToString())
{
case "All": //
actionName = "ABC";
break;
case "CurrentUser": //
actionName = "XYZ";
break;
default:
actionName = "PQR";
break;
}
<label class="control-label font-weight-bold rumaila-label">All Users: </label>
<input checked="checked"
id="radio"
name="radio"
type="radio"
value="All"
onchange="radioButtonSelected()"
/>
<label class="control-label font-weight-bold rumaila-label ml-3">Current User: </label>
<input
id="radio"
name="radio"
type="radio"
value="CurrentUser"
onchange="radioButtonSelected()"
/>
.Read(read => read.Action(actionName(getting dynamically through tempdata), "controller name").Data("radioButtonSelected"))
function radioButtonSelected() {
return {
id: $("input:radio[name=radio]:checked").val()
};
below Jquery to send the control to action method to get the actionName(same name will be used above in the grid)
$('input[type=radio][name=radio]').change(function() {
if (this.value == 'All') {
$.post('@Url.Action("ActionMethod", "Controller", new {id = "All" })', function( data ) {
});
}
else if (this.value == 'CurrentUser') {
$.post('@Url.Action("ActionMethod", "Controller", new {id = "CurrentUser" })', function( data ) {
});
}
.cs
public async Task<ActionResult> ActionName([DataSourceRequest]DataSourceRequest request)
{
DataSourceResult resultFinal = null;
string url = "api/xyz";
able to get the data from API --- through above url
return Json(new
{
Data = resultFinal.Data,
Total = resultFinal.Total,
AggregateResults = resultFinal.AggregateResults,
Errors = resultFinal.Errors,
});
}
unable to invoke the 2nd controller action based on radio selection , first action is being invoked , 2nd controlleraction method is also same as above but some logic change to get data
I facing some issue while binding the data with kendo grid
Aim : I want to call different action methods on radio button (s) selection (not kendo radio buttons) selection , my controller action will fetch the data from DB and return through Json. and binding the kendo grid with the resulted data
Issue : controller action is not being invoked.on second radio button selection
below are my code bits
.cshtml
switch (TempData["redirect"].ToString())
{
case "All": //
actionName = "ABC";
break;
case "CurrentUser": //
actionName = "XYZ";
break;
default:
actionName = "PQR";
break;
}
<label class="control-label font-weight-bold rumaila-label">All Users: </label>
<input checked="checked"
id="radio"
name="radio"
type="radio"
value="All"
onchange="radioButtonSelected()"
/>
<label class="control-label font-weight-bold rumaila-label ml-3">Current User: </label>
<input
id="radio"
name="radio"
type="radio"
value="CurrentUser"
onchange="radioButtonSelected()"
/>
.Read(read => read.Action(actionName(getting dynamically through tempdata), "controller name").Data("radioButtonSelected"))
function radioButtonSelected() {
return {
id: $("input:radio[name=radio]:checked").val()
};
below Jquery to send the control to action method to get the actionName(same name will be used above in the grid)
$('input[type=radio][name=radio]').change(function() {
if (this.value == 'All') {
$.post('@Url.Action("ActionMethod", "Controller", new {id = "All" })', function( data ) {
});
}
else if (this.value == 'CurrentUser') {
$.post('@Url.Action("ActionMethod", "Controller", new {id = "CurrentUser" })', function( data ) {
});
}
.cs
public async Task<ActionResult> ActionName([DataSourceRequest]DataSourceRequest request)
{
DataSourceResult resultFinal = null;
string url = "api/xyz";
able to get the data from API --- through above url
return Json(new
{
Data = resultFinal.Data,
Total = resultFinal.Total,
AggregateResults = resultFinal.AggregateResults,
Errors = resultFinal.Errors,
});
}
unable to invoke the 2nd controller action based on radio selection , first action is being invoked , 2nd controlleraction method is also same as above but some logic change to get data