Telerik Forums
UI for ASP.NET MVC Forum
1 answer
1.3K+ views

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?

Peter Milchev
Telerik team
 answered on 23 Nov 2016
1 answer
319 views

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.

Viktor Tachev
Telerik team
 answered on 23 Nov 2016
1 answer
188 views

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

Nencho
Telerik team
 answered on 23 Nov 2016
1 answer
499 views

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");
                            })
                        )
                    )

Danail Vasilev
Telerik team
 answered on 23 Nov 2016
1 answer
805 views

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

 

 

Konstantin Dikov
Telerik team
 answered on 23 Nov 2016
2 answers
881 views

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

Michael
Top achievements
Rank 1
 answered on 22 Nov 2016
1 answer
1.1K+ views

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);
Eyup
Telerik team
 answered on 22 Nov 2016
17 answers
327 views

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

Veselin Tsvetanov
Telerik team
 answered on 22 Nov 2016
1 answer
222 views

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");
})
))
)

Kostadin
Telerik team
 answered on 22 Nov 2016
2 answers
234 views

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.

 

Juan
Top achievements
Rank 1
 answered on 21 Nov 2016
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?