Telerik Forums
UI for ASP.NET MVC Forum
2 answers
139 views
Hi,

I have a problem when the data is shown in the grid.
I want a data from the controller, so I pass the value from the column via a script with ajax, I retrieve the value from the controller ,all fine, but that value doesn't show in the grid. I appreciate if you can help me. 

Here's my code

Html.Kendo().Grid(Model)
        .Name("Grid")
        .Columns(columns =>
        {
            columns.Bound(p => p.ID_SOLICITUDSERVICIO).Visible(false);
            columns.Command(command => command.Custom("custom").Text("").Click("MostrarSolicitud")).Title("N° de solicitud").Width(75);
            columns.Bound(p => p.NUMEROSOLICITUD_FISICO).Title("N° reporte físico");
            columns.Bound(p => p.NUMERO_SOLICITUDCLIENTE).Title("Ticket Cliente");
            columns.Bound(p => p.MARCA).Title("Marca");
            columns.Bound(p => p.MODELO).Title("Modelo");
            columns.Bound(p => p.CODIGO_REPUESTO).Title("Código del repuesto");
            columns.Bound(p => p.DETALLE_REPUESTO).Title("Detalle");
            columns.Bound(p => p.CANTIDAD).Title("Cantidad");
            columns.Bound(p => p.VALOR_UNITARIO).Title("Valor unit.");
            columns.Bound(p => p.VALOR_TOTAL).Title("Valor total").ClientFooterTemplate("$ #=sum#");
            columns.Bound(p => p.PROPIETARIO).Title("Propietario");
            columns.Bound(p => p.ID_REPUESTOSERVICIO)
                //.ClientTemplate("#= Texto_Factura(data) #")
                .Title("N° factura");
            //columns.Bound(p => p.ID_REPUESTOSERVICIO)
            //    .ClientTemplate("#= CheckDevoler(data) #")
            //    .Title("Devolver").Width(60)
            //.Sortable(false).Groupable(false).Filterable(false);
        })
                .Filterable()
                .Sortable()
                .Pageable(m => m.PageSizes(new int[] { 10, 20, 50, 100, 500 }))
                .Groupable()
                .Events(e => e.DataBound("dataBound"))
        .DataSource(dataSource => dataSource
            .Ajax()
            .Read(read => read.Action("LeerExt_DevolucionRepuesto", "Consultas").Data("getParameter"))
                    .Model(model => { model.Id(p => p.ID_SOLICITUDSERVICIO); })
                    .Aggregates(aggregate =>
                   {
                       aggregate.Add(p => p.VALOR_TOTAL).Sum();
                   })
        )

that's the script. in the alert appear the value that i want

<script type="text/javascript">
  
    function Texto_Factura(item) {
        var texto = "<label></label>";
        var urls = "/Consultas/GetRepuestoServicioSinById";
        var idrepuesto = item.ID_REPUESTOSERVICIO;
        var factura = "";
 
        $.ajax({
            url: urls,
            data: { id_repuestoservicio: idrepuesto },
            type: 'GET',
            success: function (data) {
                if (data.FACTURA_REPUESTOSERVICIO != null) {
 
                    factura = data.FACTURA_REPUESTOSERVICIO;
                    alert("<label>" + kendo.htmlEncode(factura) + "</label>");
                    return texto = "<label>" + kendo.htmlEncode(factura) + "</label>";
                }
            },
            error: function (resp) {
                //alert(JSON.stringify(resp));  open it to alert the error if you want
                alert(resp);
                return texto = "<label>" + resp + "</label>";
            }
        });
return texto;
    }
</script>

Thanks.
Misahael
Top achievements
Rank 1
 answered on 11 Mar 2014
1 answer
44 views
Hi

I have two grids.

Grid 1 - User filters out records that are not required.

Grid 2 - I would like to show the records that have been filtered out of Grid 1

Please can you tell me the best way to acheive this?

Kind Regards

David
Alexander Popov
Telerik team
 answered on 11 Mar 2014
1 answer
385 views
I have a grid where when expanding a row I have a dropdownlist that loads it's items via ajax/json.

Now, when I expand multiple rows in 1 shot - the back end controller method used to load the items is called for each drop down (1 per detail expanded row) where the ddl's items are identical for each ddl.

Is there any way client side that we could have multiple dropdownlists refer to one set of items for selection?

Basically - something like:

a) call the controller method via ajax and get the items.
b) have each ddl point to that collection of items

Caching on the server is not an option.
Daniel
Telerik team
 answered on 11 Mar 2014
7 answers
587 views
Hello,
I'm using the sync upload widget.
I would like to be able to add an a custom unique id attribute to the inputs of the files selected.
Unfortunately, the inputs are created after the "Selected" event.
Is there any way i can achieve this?
Dimiter Madjarov
Telerik team
 answered on 11 Mar 2014
5 answers
217 views
Hi,

I have a grid that has a number of columns that will effectively involve horizontal scrolling to see the whole row of data.

I was wondering is it possible to have the first column not scroll and act as a key to the row when the user does scroll horizontally.

Has anyone else had a similar problem, as I have parred down the columns as much as I can.

regards

Pb
Dimo
Telerik team
 answered on 11 Mar 2014
1 answer
246 views
Hi there,

I am using DatePicker in my web page as this.
<td class="td-header-input">
@(Html.Kendo().DatePickerFor(p => p.MyDate).Format("MM/dd/yyyy").ParseFormats(new String[] { "MM/dd/yyyy" })
                                              .HtmlAttributes(new { id = "date_1", data_bind = "value: MyDate", @class = "header-input header-dropdownlist heasder-datepicker", style = "width:100px" })
                                             )
</td>

Instead of the default calendar image shown to the right side of datepicker, I would like to use my own version of image. I tried to set .k-i-calendar like this
.k-i-calendar {
  background: url(../images/myCalendaricon.png) no-repeat center;
  display: inline-block;
}

But nothing shows. not even the default calendar image. Can someone tell me how to use my own image in datePicker?

Thanks.

Dimo
Telerik team
 answered on 10 Mar 2014
2 answers
406 views
I've been having alot of problems getting the MVC extensions working. I finally resorted to starting up a brand new "c# Kendo UI for MVC Web Application". I start it up and straight away in the Chrome developer tools I see the following errors:

Uncaught SyntaxError: Invalid regular expression: missing / kendo.all.min.js:10
Uncaught TypeError: Cannot read property 'jQuery' of undefined kendo.aspnetmvc.min.js:10

I checked all the FQAs about these errors and confirmed that everything (web.config, Single JQuery reference, etc...) and everything looks good. Moreover, I tried to add a grid and I'm seeing :

Uncaught TypeError: Object [object Object] has no method 'kendoGrid'

I've attached the sample project that I created.
Bil
Top achievements
Rank 1
 answered on 10 Mar 2014
3 answers
897 views
Hi,

I have two series of type

Series 1: {Date:1/1/2011,Hitcount:3,Date:1/12/13,Hitcount 4}

Series 2:{Date :1/1/2011,Hitcount 5,Date:1/12/13:Hitcount 5}

How do I generate Multiple series using dynamic binding

my kendo chart currently looks liek this 

  @(Html.Kendo().Chart<kendoNet.Models.ChartSeries>() // The chart will be bound to the Model which is the InternetUsers lis
                      .Name("Chart3")
                      .Title("Test")


                // The name of the chart is mandatory. It specifies the "id" attribute of the widget.
                       .DataSource(dataSource =>
                                dataSource.Read(read => read.Action("Series", "Home", new  { plname=ViewBag.Pl,test="VCS"})) // Specify the action method and controller name
                                )
                                .Legend(legend => legend
                                    .Position(ChartLegendPosition.Bottom)
                                ).ChartArea(chartArea => chartArea
                                    .Background("transparent")
                                ).SeriesDefaults(seriesDefaults =>
                                    seriesDefaults.Line().Style(ChartLineStyle.Smooth)
                                )
                                .Series(series =>
                                {
                                       //MODEL IS DICTIONARY CONTAINING THE TWO SERIES 1 AND SERIES 2 ,HOW DO WE DISPLAY MULTIPLE SERIES HERE
                                      series.Line(model => model.Values).Name("HitCount").Labels(labels => labels.Visible(true).Color("Red")).Color("Blue");                                                

                                })

                                .CategoryAxis(axis => axis
                                //.Categories(model => model.Date)
                                .Labels(labels => labels.Rotation(-65)

                                )

                                )
                       
                        .ValueAxis(axis => axis
                            .Numeric().Labels(labels => labels.Format("{0}"))
                            .Line(line => line.Visible(false))
                            .AxisCrossingValue(-10)
                        )
                        .Tooltip(tooltip => tooltip
                            .Visible(true)
                            .Format("{0}")
                        )
        )
Daniel
Telerik team
 answered on 10 Mar 2014
2 answers
394 views
Hi 
How to add check box in panelbar item and binding data from entity framework.  
Petur Subev
Telerik team
 answered on 10 Mar 2014
2 answers
523 views

I am missing something important regarding this example grid

    http://demos.telerik.com/kendo-ui/web/grid/editing-custom.html?mvc

I based my shopProductAdmin view/controller closely on this example, making use of the custom editor used in the example for CategoryViewModel, for my priceStrategyViewModel.

Other differences from the reference, 
I am using InLine editing instead of InCell.  
I am not using Batch mode.
The read function has additional data it sends to get the products.
The read/update/delete functions all have role requirement hints for security, but i tested without these security hints and the behavior is the same.

There is something not right about the data being passed around though.  Some binding somewhere must be amiss and I can't seem to spot it.
Bad behaviors I see..

a) the default priceStrategy, when no record exists in the database, the PriceStrategyViewData.priceStrategyID/name are populated with the 99_none and the proper index.  That part works.
b) when I edit a field, the customEditor comes up.. good
c) the value of the priceStrategy changes from 99_none to the first value in the priceStrategies list -- bad!. it should still be 99_none.  This is the first indication that some data is not being passed around properly.
d) when I update the record on the grid, the update function in the controller see's the new product and all fields are properly updated with the notable exception of the PriceStrategyViewModel.* fields.

One piece of code in the example that I haven't gleaned why it is there.. in the example that I found on the installation package.. (this isn't shown on the web version, as the entities are not part of the sample code there), the entity not only has a 
  public CategoryViewModel Category { get; set; }
member.. which I understand that.  But it also has this member right after it.. which seems to have no function anywhere in the grid.  Was this intentional?  I included it in my model also only to be consistent, but I haven't decided why it is there.  It seems like it isn't serving a purpose.

          public int? CategoryID { get; set; }

Anyway, here is my grid in the Admin.cshtml


                @(Html.Kendo().Grid<EveTools.WebUI.Models.shopProductsAdminViewModel>()
                    .Name("productsGrid")
                    .Columns(columns =>
                    {
                        columns.Bound(product => product.typeName).Width(200).Title("Shop");
                        columns.Bound(product => product.forSale).Title("ForSale?");
                        columns.Bound(product => product.PriceStrategy).ClientTemplate("#=PriceStrategy.name#").Width(150);
                        columns.Bound(product => product.markup).Title("markup").Width(50);
                        columns.Bound(product => product.price).Title("Price");
                        columns.Command(command => { command.Edit();  command.Destroy().Text("Clear"); }).Width(100);
                    })
                    .DataSource(dataBinding => dataBinding
                        .Ajax()
                        .ServerOperation(false)                        
                        .Model(model => model.Id(p => p.typeID))
                        .Read(read => read.Action("ProductListAdmin", "Shop").Data("additionalProductListData"))
                        .Destroy(update => update.Action("EditingInline_DeleteProduct", "Shop"))
                                .Update(update => update.Action("EditingInline_UpdateProduct", "Shop"))
                        .Events(events => events.Error("error_handler"))
                        .Model(model =>
                        {
                            model.Id(p => p.typeID);
                            model.Field(p => p.typeName).Editable(false);
                            model.Field(p => p.price).Editable(false);
                            model.Field(p => p.PriceStrategy).DefaultValue(
                                ViewData["defaultPriceStrategy"] as EveTools.WebUI.Models.PriceStrategyViewModel);
                        })
                    )
                    .Editable(editable => editable.Mode(GridEditMode.InLine))
                    .Pageable()
                    .Sortable()
                    .Scrollable()
                    .HtmlAttributes(new { style = "height:480px;" })

And the critical controller functions.

This function returns the data to the grid when requested.. by means of another list control of categories.

        public ActionResult ProductListAdmin([Kendo.Mvc.UI.DataSourceRequest]Kendo.Mvc.UI.DataSourceRequest request, int? categoryID)
        {
            // if there is no category, there are also no products
            if (!categoryID.HasValue)
                return null;

            EveShop.Domain.Concrete.EFEveShopDbContext db = new EveShop.Domain.Concrete.EFEveShopDbContext();

            PriceStrategyViewModel defaultPriceStrategy = GetDefaultPriceStrategy();

            // extract data from db, and fill in shopProductsAdminViewModels
            var products = (from t in db.invTypes
                            join p in db.shopProducts
                            on t.invTypeID equals p.shopProductID into output
                            from o in output.DefaultIfEmpty()
                            select new shopProductsAdminViewModel
                            {
                                typeID = t.invTypeID,
                                groupID = t.groupID,
                                typeName = t.typeName,
                                volume = t.volume,
                                basePrice = t.basePrice,
                                published = t.published,
                                marketGroupID = t.marketGroupID,
                                iconID = t.iconID,
                                markup = (t.shopProduct == null) ? 0 : t.shopProduct.markup,
                                forSale = (t.shopProduct == null) ? false : t.shopProduct.forSale,
                                price = (t.shopProduct == null) ? 0 : t.shopProduct.shopProductPrice.price,
                                // not sure why i am filling this one in.. it was included in the original example though.. no binding to the grid?
                                priceStrategyID = (t.shopProduct == null) ? defaultPriceStrategy.priceStrategyID : t.shopProduct.shopPriceStrategy.shopPriceStrategyID,
                                // the actual price strategy data.. this one gets bound to the grid
                                PriceStrategy = new PriceStrategyViewModel
                                {
                                    priceStrategyID = (t.shopProduct == null) ? defaultPriceStrategy.priceStrategyID : t.shopProduct.shopPriceStrategy.shopPriceStrategyID,
                                    name = (t.shopProduct == null) ? defaultPriceStrategy.name : t.shopProduct.shopPriceStrategy.name
                                }
                            }).Where(e => e.marketGroupID == categoryID && e.published != false)
                    .OrderBy(e => e.typeName)

            return Json(products.ToDataSourceResult(request));
        }


This function receives the update record callback

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult EditingInline_UpdateProduct([DataSourceRequest] DataSourceRequest request, shopProductsAdminViewModel product)
        {
            // do something with updated product
            // product.priceStrategy.* is always the default value, not the edited value.

            return Json(new[] { product }.ToDataSourceResult(request, ModelState));
        }

The PriceStrategyViewModlEditor.cshtml

@model EveTools.WebUI.Models.PriceStrategyViewModel
       
@(Html.Kendo().DropDownListFor(m => m)
        .Name("PriceStrategyViewModel")
        .DataValueField("priceStrategyID")
        .DataTextField("name")
        .BindTo((System.Collections.IEnumerable)ViewData["priceStrategies"])
)












Paul
Top achievements
Rank 1
 answered on 10 Mar 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
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?