This is the situation:
I have a form that when i click in the submit button is sending a file
with the kendo upload control, and the method action of the controller
is receiving that file in the parameter with the HttpPostedFileBase.
This is my HTML code:
@using (Html.BeginForm("ConfirmarOposicion", "Gestion", FormMethod.Post, new { @id = "Frm-login", role = "form", @class = "form-horizontal" }))
{
@(Html.Kendo().Upload()
.Name("files")
)
<button class="btn btn-success" type="submit" id="confirm" >Confirm</button>
}
And this is my controller:
public async Task<ActionResult> ConfirmarOposicion(IEnumerable<HttpPostedFileBase> files)
{
// Here the parameter files is not null..
}
Here is working all good till now. The problem is when i try to send
more values as parameter into the same method of the controller.
The other values that i want to send is an array, and the other is a
number.
This two values i try to send with ajax in javaScript.
This is my javaScript code when i try to send those two more values:
$("#confirm").click(function ()
{
var numMarca = $("#numMarca").val()
var idsToSend = [];
var grid = $("#Grid2").data("kendoGrid")
var ds = grid.dataSource.view();
for (var i = 0; i < ds.length; i++)
{
var row = grid.table.find("tr[data-uid='" + ds[i].uid + "']");
var checkbox = $(row).find(".checkbox");
if (checkbox.is(":checked"))
{
idsToSend.push(ds[i].DescMarca);
idsToSend.push(ds[i].IntencionOposicion = 1);
}
else
{
idsToSend.push(ds[i].DescMarca);
}
}
$.ajax({
url: '@Url.Action("ConfirmarOposicion", "Gestion")',
data: { ids: idsToSend, marca: numMarca },
type: 'POST',
dataType: "json",
success: function (data)
{
...
}
When i clik the submit button is sending this two values in the same controller that i send the input file.
And this my controller now:
public async Task<ActionResult> ConfirmarOposicion(IEnumerable<HttpPostedFileBase> files, string[] ids, string marca)
{
// here the array ids and the value of marca is not null, but the parameter files it is null
}
And that's the issue that i have.
I need to send all those values in the same method action of the controller.
How can i do that?
This is a two part question, first how do I know what controller parameters are needed fro the update action for the tree view (Same question applies to all Kendo controls) No error is thrown so I don't known what route (route signature) to build.
Second, could be related to the first my action is public JsonResult Update([DataSourceRequest] DataSourceRequest request, ProductViewModel product) but when I do a drag and drop the action isn't fired. I have found when this happens typically it is because I don't have a matching signature for the route... but again no error is thrown so I can't debug it.
Thanks in advance and sorry if I am not using the correct terminology for this.
Hi,
it seems that the selection in the AutoComplete is not correct (see attached Pictures) - it should be the same as the other Dropdowns (Combo, list)
robert
I would like to refersh a layer in a kendo Map, there are 8 layers, but only want to refresh layer 1.
This would occur on a button click event.
my datasource for the layer is
.DataSource(source => source
.Custom()
.Transport(transport => transport
.Read(read =>
{
read.Url("/Api/EventInfo/_P4BubbleAreas/" + Model.showEventP4.ToString())
.DataType("json");
})
)
)
Hi,
I have a partial view that is referring to a model. I can open multiple models at the same time, which reflects in having that particular partial view shown multiple times.
The problem now is that every controlinside of it has an id (grids, multiselects ...), and by showing it multiple times I get into the situation that I have multiple controls with a same id.
Actually I can open it just 2 times, bcz then the controls get "broken" and dont load properly anymore (I need to refresh the page to get it working again).
Is there a way around that, best practice or smt ?
Regards
Hi,
i want to change the text color of a foreign key column depending on the values of two other columns.
I do this for a bounded column using a client template:
columns.Bound(p => p.CompanyAlternative).ClientTemplate("# if ( LeIdOriginal === LeIdAlternative) { # <div> #= CompanyAlternative # </div> # } else { # <div style='color: rgb(225,0,15);'> #= CompanyAlternative # </div> # } #");
But how can i achieve this for a foreign key?
Thanks
Michael
Hello,
I have a custom command column in my grid as seen below. I would like to change the text of the button from "Activate" to "Deactivate" based on 2 other cells values in the row. How can I do this? Thanks.
col.Command(command => command.Custom("Activate").Click("activate_deactivate")).Locked(true).Width(140);
Hi,
I have pretty complex appointment classes (with lots of dependencies). Now when I want to display them inside the scheduler I just read the most important information (start, end, title ...). But when I want to edit the appointment with my custom template, I want to load all the additional information (it would be too slow to load all that data for the scheduler).
So is there a possiblity to "reload" my object before showing it inside the template ?
Regards
Semir
I have a grid that I want to display inside a ClientTemplate, but the datasource is not binding
What am I missing to get the bind to occur.
Thanks
@(Html.Kendo().Grid<WebSite.Library.Models.SiteCriteria>()
.Name("siteCriteriaCriteria")
.Columns(columns =>
{
columns.Bound(p => p.siteId).Title("siteId").Width(50).Hidden();
//columns.Bound(p => p.premiseAreaId).Title("premiseId").Width(50).Hidden();
columns.Bound(p => p.areaId).Title("AreaId").Width(50).Hidden();
columns.Bound(p => p.name).Title("Hazard Area").Width(150);
columns.Template(p => "").Title("criteria").ClientTemplate(
Html.Kendo().Grid<WebSite.Library.Models.SiteCriteria>()
.Name("areaCriteria#=areaId#")
.Columns(c =>
{
c.Bound(e1 => e1.name).Title("Training").Width(100);
})
.AutoBind(true)
.DataSource(source1 => source1
.Custom()
.Transport(transport => transport
.Read(read =>
{
read.Url("/Api/SiteInfo/_getTrainingAreas/_si=12117")
.DataType("json");
})
))
.ToClientTemplate()
.ToHtmlString()
);
})
//.Events(events => events.Remove("onRemove"))
.NoRecords("No criteria exists.")
.DataSource(source => source
.Custom()
.Transport(transport => transport
.Read(read =>
{
read.Url("/Api/SiteInfo/_getPremiseArea/_si=" + Model.SiteId )
.DataType("json");
})
))
)
Please i need someone can help me with this problem.
I'm trying to send the selected rows into a controller when i click on the button with id="send", the issue is that when i tried to send other values( in this case a number and a string) with the selected rows values, the selected rows values is sending null to the controller but the number and the string isn't null in the controller parameters.
This is my javascript code that works fine if only i send the selected rows values:
$('#send').click(function () {
var items = {};
var grid = $('#grid').data('kendoGrid');
var selectedElements = grid.select();
for (var j = 0; j < selectedElements.length; j++) {
var item = grid.dataItem(selectedElements[j]);
items['grid[' + j + '].ParecidoCodigo'] = item.ParecidoCodigo;
}
$.ajax({
url: '@Url.Action("Index", "Busqueda")',
type: "POST",
async: false,
data: items,
success: function (result) {
console.log(result);
}
})
})
and this is my controller method action:
public ActionResult Index(MarcaParecido[] grid)
{
...
}
Everything works fine until now.
BUt when i tried to send another values like this:
$('#send').click(function () {
var items = {};
var grid = $('#grid').data('kendoGrid');
var selectedElements = grid.select();
var enviarDest = $('#destinatario').val();
var marca = $('#numMarca').val();
for (var j = 0; j < selectedElements.length; j++) {
var item = grid.dataItem(selectedElements[j]);
items['grid[' + j + '].ParecidoCodigo'] = item.ParecidoCodigo;
}
$.ajax({
url: '@Url.Action("Index", "Busqueda")',
type: "POST",
async: false,
data: { items, marcas: marca, destinatario: enviarDest },
success: function (result) {
console.log(result);
}
})
})
The selected rows values is sending me null, but hte others values isn't null
This is my controller now:
public ActionResult Index(MarcaParecido[] grid, string marcas, string destinatario)
{...}
Please i really need your help with this, i don't know what else can i do to send all the values when i click the button.
I tried with JSON.stringify too but it doesn't work :(
I'll wait for your answers. Big hugs.