This is a migrated thread and some comments may be shown as answers.

From grid nested get row number

9 Answers 304 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Xavier
Top achievements
Rank 1
Xavier asked on 05 Feb 2016, 02:14 PM

Hi,

 When I try to get row number from the second grid nested I get null value. Do you know the way to get the correct value?

 

@(Html.Kendo().Grid<ExpeditionViewModel>()
        .Name("expeditions")
        .HtmlAttributes(new { style = "height: 100%; border: 0;" })
        .Scrollable()
        .ToolBar(t =>
        {
            if (User.IsInRole("Modify"))
            {
                t.Create().Text("Nova Expedició");
            }
        })
        .Columns(columns =>
        {
            columns.Bound(f => f.ExpeditionID).Width(100);
            columns.Bound(f => f.Data).Width(80);
            columns.ForeignKey(f => f.TransportID, (System.Collections.IEnumerable)ViewBag.Transports, "ContactID", "CodAutor").Width(100);
            columns.Bound(f => f.Matricula).Width(80);
            columns.ForeignKey(f => f.XoferID, (System.Collections.IEnumerable)ViewBag.Xofers, "PersonID", "Nom").Width(200);
            columns.ForeignKey(f => f.OrigenID, (System.Collections.IEnumerable)ViewBag.Centres, "ContactID", "CodAutor").Visible(false);
            columns.ForeignKey(f => f.DestiID, (System.Collections.IEnumerable)ViewBag.Centres, "ContactID", "CodAutor").Width(80);
            columns.Bound(f => f.Kg).HtmlAttributes(new { style = "text-align: right;" }).Width(90);
            columns.Bound(f => f.Ticket).Width(80);
            columns.Bound(f => f.Reparto).HtmlAttributes(new { style = "text-align: right;" }).Width(80);
            columns.Bound(f => f.TotalLitres).HtmlAttributes(new { style = "text-align: right;" }).Width(90);
            columns.Bound(f => f.TotalKg).HtmlAttributes(new { style = "text-align: right;" }).Width(90);
            if (User.IsInRole("Modify"))
            {
                columns.Command(commands =>
                {
                    commands.Edit();
                    commands.Destroy();
                });
            }
        })
        .Editable(e => e.Mode(GridEditMode.PopUp).Window(w => w.Width(330)))
        //.Events(e => e
        //    .Edit("expedition_onEdit")
        //)
        .Pageable(pageable => pageable.Refresh(true))
        .Sortable()
        .Filterable()
        .ClientDetailTemplateId("Expedition_DetailTemplate")
        .DataSource(dataSource => dataSource
            .Ajax()
            .PageSize(18)
            .Model(m =>
            {
                m.Id(f => f.ExpeditionID);
                m.Field(f => f.TransportID).DefaultValue(ViewBag.DefaultTransportID);
                m.Field(f => f.OrigenID).DefaultValue(ViewBag.DefaultCentreID);
                m.Field(f => f.DestiID).DefaultValue(ViewBag.DefaultCentreID);
            })
            .Events(e => e
                .Error(@<text> function(e) { onError(e, "expeditions"); }</text>)
            )
            .Sort(s => s.Add(f => f.ExpeditionID).Descending())
            .Read("ExpeditionRead", "Planning")
            .Create("ExpeditionCreate", "Planning")
            .Update("ExpeditionUpdate", "Planning")
            .Destroy("ExpeditionDestroy", "Planning")
        )
    )
 
    @{
        Func<object, object> expeditionDetailError = @<text>
            function(e) {
                if (e.errors) {
                    onError(e, "expeditionDetail_#=ExpeditionID#");
                }
            }
        </text>;
 
        Func<object, object> expeditionRequestEnd = @<text>
            function(e) {
                onRequestEnd(e, "expeditionDetail_#=ExpeditionID#");
            }
        </text>;
 
        Func<object, object> expeditionEdit = @<text>
            function(e) {
                expeditionDetail_onEdit(e, "expeditionDetail_#=ExpeditionID#");
            }
        </text>;
    }
 
    <script id="Expedition_DetailTemplate" type="text/x-kendo-tmpl"><=== Second Grid
        <div class="row">
            @(Html.Kendo().Grid<ExpeditionDetailViewModel>()
                .Name("expeditionDetail_#=ExpeditionID#")
                .ToolBar(t =>
                {
                    if (User.IsInRole("Modify"))
                    {
                        t.Create().Text("Afegir Servei");
                    }
                })
                .Columns(columns =>
                {
                    columns.Bound(f => f.ServiceID).Width(80);
                    columns.Bound(f => f.ProductorID).Hidden();
                    columns.Bound(f => f.CodAutor).Width(80);
                    columns.Bound(f => f.ProductorName).Width(350).Filterable(f => f.Operators(g => g.ForString(h => { h.Clear(); h.Contains("Conté"); })));
                    columns.Bound(f => f.Poblacio).Filterable(f => f.Operators(g => g.ForString(h => { h.Clear(); h.Contains("Conté"); })));
                    columns.Bound(f => f.DataOrdre).Width(80);
                    columns.ForeignKey(f => f.HolderID, (System.Collections.IEnumerable)ViewBag.Centres, "ContactID", "CodAutor").Width(80);
                    columns.ForeignKey(f => f.DocTypeID, (System.Collections.IEnumerable)ViewBag.DocTypes, "OptionID", "ShortName").Width(50);
                    columns.Bound(f => f.DocNum).Width(80);
                    columns.Bound(f => f.JustNum).Width(40);
                    columns.ForeignKey(f => f.Reference, (System.Collections.IEnumerable)ViewBag.CatalegResidus, "Value", "Text");
                    columns.Bound(f => f.Litres).Width(60);
                    columns.Bound(f => f.Kg).Width(60);
                    columns.ForeignKey(f => f.StateID, (System.Collections.IEnumerable)ViewBag.ServiceStates, "OptionID", "Name").Width(100);
                    columns.ForeignKey(f => f.OwnerID, (System.Collections.IEnumerable)ViewBag.Users, "PersonID", "Nom").Visible(false);
                    if (User.IsInRole("Modify"))
                    {
                        columns.Command(commands =>
                        {
                            commands.Edit();
                            commands.Destroy();
                        });
                    }
                })
                .Editable(e => e.Mode(GridEditMode.PopUp).TemplateName("ExpeditionDetailEdit"))
                .Events(e =>
                {
                    e.Edit(expeditionEdit);<== Event Edit
                })
                .Pageable(pageable => pageable.Refresh(true))
                .DataSource(dataSource => dataSource
                    .Ajax()
                    .Model(model =>
                    {
                        model.Id(a => a.ServiceID);
                        model.Field(f => f.HolderID).DefaultValue(ViewBag.DefaultCentreID);
                        model.Field(f => f.StateID).DefaultValue((short)serviceState.Planned);
                        model.Field(f => f.OwnerID).DefaultValue(ViewBag.Usuari);
                    })
                    .Events(e => e
                        .Error(expeditionDetailError)
                        .RequestEnd(expeditionRequestEnd)
                    )
                    .Read("ServiceRead", "Planning", new { ExpeditionID = "#=ExpeditionID#" })
                    .Create("ServiceCreate", "Planning", new { ExpeditionID = "#=ExpeditionID#" })
                    .Update("ServiceUpdate", "Planning")
                    .Destroy("ServiceDestroy", "Planning")
                ).ToClientTemplate()
            )
        </div>
    </script>
</div>

Event Edit

function expeditionDetail_onEdit (e, gridName) {
        if ($("#DocTypeID").val() != @((short)documentType.FI))
            $("#JustNum").hide();
 
        var grid = $("#"+gridName).data("kendoGrid");
        //var data = grid.dataItem($(this).closest("tr"))
        var row = grid.tbody.children(".k-grid-edit-row");<== row = null
        var data = grid.dataItem("tr:eq(0)");
 
         
        //var grid = $("#"+gridName).data("kendoGrid");
        //var row = grid.dataItem(this.select());
        //var row = grid.tbody.children(".k-grid-edit-row");
 
        //var codi = row.find("[name=ServiceID]").text();
        //var name = row.find("[name=ProductorID]").text();
         
        //var productor = codi + ' - ' + name;
         
 
        //$("#ProductorID").data("kendoComboBox").input.val(productor);
 
         

Popup Template

<div class="container-fluid">
    <div class="row">
        <div class="form-horizontal col-md-12" style="width:905px">
            @Html.ValidationSummary(true, "", new { @class = "text-danger" })
            <div class="form-group">
                @Html.LabelFor(model => model.DataOrdre, new { @class = "col-md-1 control-label" })
                <div class="col-md-2">
                    @Html.EditorFor(model => model.DataOrdre)
                </div>
                @Html.LabelFor(model => model.HolderID, new { @class = "col-md-1 control-label" })
                <div class="col-md-2">
                    @Html.EditorFor(model => model.HolderID)
                </div>
            </div>
 
            <div class="form-group">
                @Html.LabelFor(model => model.DocTypeID, new { @class = "col-md-1 control-label" })
                <div class="col-md-1">
                    @Html.EditorFor(model => model.DocTypeID)
                </div>
                <div class="col-md-1">
                    @Html.Kendo().TextBoxFor(m => m).Name("DocNum").HtmlAttributes(new { style = "width:100px" })
                </div>
                <div class="col-md-1">
                    @Html.Kendo().TextBoxFor(m => m).Name("JustNum").HtmlAttributes(new { style = "width:40px", maxlength = "2" })
                </div>
            </div>
 
            <div class="form-group">
                @Html.LabelFor(model => model.ProductorID, new { @class = "col-md-1 control-label" })
                <div class="col-md-4">
                    @Html.EditorFor(model => model.ProductorID)
                </div>
            </div>
 
            <div class="form-group">
                @Html.LabelFor(model => model.Observacions, new { @class = "col-md-1 control-label" })
                <div class="col-md-9">
                    @Html.TextAreaFor(model => model.Observacions, new { @class = "form-control", @rows = 5 })
                </div>
            </div>
 
            <div class="form-group">
                @Html.LabelFor(model => model.Reference, new { @class = "col-md-1 control-label" })
                <div class="col-md-2">
                    @Html.EditorFor(model => model.Reference)
                </div>
                @Html.LabelFor(model => model.Litres, new { @class = "col-md-1 control-label" })
                <div class="col-md-2">
                    @Html.EditorFor(model => model.Litres)
                </div>
                @Html.LabelFor(model => model.Kg, new { @class = "col-md-1 control-label" })
                <div class="col-md-2">
                    @Html.EditorFor(model => model.Kg)
                </div>
            </div>
 
            <div class="form-group">
                @Html.LabelFor(model => model.Incidencies, new { @class = "col-md-1 control-label" })
                <div class="col-md-9">
                    @Html.TextAreaFor(model => model.Incidencies, new { @class = "form-control", @rows = 5 })
                </div>
            </div>
 
            <div class="form-group">
                @Html.LabelFor(model => model.OwnerID, new { @class = "col-md-1 control-label" })
                <div class="col-md-2">
                    @Html.EditorFor(model => model.OwnerID)
                </div>
                @Html.LabelFor(model => model.StateID, new { @class = "col-md-1 control-label" })
                <div class="col-md-2">
                    @Html.EditorFor(model => model.StateID)
                </div>
            </div>
        </div>
    </div>
</div>

 

Thanks in advance.

 

 

 

9 Answers, 1 is accepted

Sort by
0
Venelin
Telerik team
answered on 09 Feb 2016, 12:01 PM
Hello Xavier,

You can use the following approach:

function edit(e) {
    var grid = e.sender;
    var dataRows = grid.items();
    console.log(dataRows.index($("[data-uid=" + e.model.uid + "]")));
}

Regards,
Venelin
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Xavier
Top achievements
Rank 1
answered on 10 Feb 2016, 09:52 AM
Thanks Vennelin.
0
Xavier
Top achievements
Rank 1
answered on 17 Feb 2016, 03:09 PM

Hi again,

Thanks for the infomation, but the problem persist, because in  popup template on line @Html.EditorFor(model => model.ProductorID) uses a combobox:

 

@(Html.Kendo().ComboBoxFor(m => m)
    .Name("ProductorID")
    .HtmlAttributes(new { style = "width:400px" })
    //.AutoBind(false)
    //.Placeholder("Escriu...")
    .DataTextField("Description")
    .DataValueField("ContactID")
    .Filter(FilterType.Contains)
    .MinLength(4)
    .DataSource(source =>
    {
        source.Read(read => read.Action("SearchProductors", "Auxiliary", new { area = "" }).Data("filterProductors"))
            .ServerFiltering(true);
    })
    .Events(e => e
        .Change(onChange)
    )
    //.HeaderTemplateId("ProductorSearch_HeaderTemplate")
    //.TemplateId("ProductorSearch_ItemTemplate")
)

 

public async Task<JsonResult> SearchProductors(string textFilter, bool Actiu = true, bool allRoutes = false)
       {
           var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
           var rutesAutoritzades = user.AuthorizedRoutes.Split(',').ToList();
 
           var productors = ens.ProdCensus.Where(p => allRoutes || rutesAutoritzades.Contains("*") == true || rutesAutoritzades.Count(r => p.Ruta.Contains(r) == true) > 0).Select(p => new
           {
               ContactID = p.ContactID,
               Description = p.CodAutor + " - " + p.Nom + " - " + p.Poblacio,
               CodAutor = p.CodAutor,
               Nom = p.Nom,
               Poblacio = p.Poblacio,
               Baixa = p.Baixa
           });
 
           if (Actiu)
               productors = productors.Where(p => p.Baixa == null);
 
           if (!String.IsNullOrWhiteSpace(textFilter))
           {
               //productors = productors.Where(p => (p.CodAutor + " " + p.Nom).Contains(textFilter));
               productors = productors.Where(p => p.Description.Contains(textFilter));
           }
           else
               productors = null;
 
           return Json(productors, JsonRequestBehavior.AllowGet);
       }

 

On event edit from grid I get productor's data on combobox list. but I cannot assign this data to combobox value property. It's possible to find a way to resolve this behavior.

 

function expeditionDetail_onEdit(e, gridName) {
 
var grid = e.sender;
        var dataRows = grid.items();
        var rowNumber = dataRows.index($("[data-uid=" + e.model.uid + "]"));
        rowNumber++;
        //grid.dataItem("tr:eq(" + rowNumber + ")");
        var rowData = grid.dataItem("tr:eq(" + rowNumber + ")");
 
        var contact = rowData.get("ProductorID");
        var codi = rowData.get("CodAutor");          
        //var name = rowData.get("ProductorName");
        //var poblacio = rowData.get("Poblacio");
        //var descripcio = codi + ' - ' + name + ' - ' + poblacio;
 
        var cboProductor = $("#ProductorID").data("kendoComboBox");
        cboProductor.value(codi);
 
        cboProductor.open();
        cboProductor.close();
}

Thanks in advance.

 

 

Xavier.

0
Venelin
Telerik team
answered on 18 Feb 2016, 06:57 AM
Hi Xavier,

I am confused about what the exact problem is. In your first post the problem described was: "When I try to get row number from the second grid nested I get null value" and in the next: "but the problem persist, because in  popup template on line @Html.EditorFor(model => model.ProductorID) uses a combobox". Could you please explain what's the behavior you expect to achieve?

Regards,
Venelin
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Xavier
Top achievements
Rank 1
answered on 18 Feb 2016, 10:46 AM
Sorry, it's a different question. Now I need show productor's value when I edit. Concretly the grid has a template popup with the combobox, I need to know how to show the Productor value, for this reason I send you the code of combobox and the event edit of grid.
0
Xavier
Top achievements
Rank 1
answered on 18 Feb 2016, 05:14 PM

Hi Venelin,

If you allow me I can explain the problem again. 

I have a grid with mode popup and template "CollectEdit".

@(Html.Kendo().Grid<CollectViewModel>()
        .Name("collects")
        .HtmlAttributes(new { style = "height: 100%; border: 0;" })
        .Scrollable()
        .ToolBar(t =>
        {
            if (User.IsInRole("Modify"))
            {
                t.Create().Text("Nou Servei");
            }
        })
        .Columns(columns =>
        {
            columns.Bound(f => f.ServiceID).Width(80);
            columns.ForeignKey(f => f.OrderTypeID, (System.Collections.IEnumerable)ViewBag.OrderTypes, "OptionID", "Name").Visible(false);
            columns.Bound(f => f.DataOrdre).Width(80);
            columns.ForeignKey(f => f.HolderID, (System.Collections.IEnumerable)ViewBag.Centres, "ContactID", "CodAutor").Width(80);
            columns.Bound(f => f.Urgent).ClientTemplate("# if(Urgent) { # <img src='" + Url.Content("~/Content/img/success.png") + "' alt='Sí' Height='16px' Width='16px' /> # } #").Width(40);
            columns.Bound(f => f.DataClaim).Width(80);
            columns.Bound(f => f.DataServei).Width(80);
            columns.ForeignKey(f => f.DocTypeID, (System.Collections.IEnumerable)ViewBag.DocTypes, "OptionID", "ShortName").Visible(false);
            columns.Bound(f => f.DocNum).Width(80);
            columns.Bound(f => f.JustNum).Width(40);
            columns.Bound(f => f.ProductorID).Hidden();
            columns.Bound(f => f.CodAutor).Width(80);
            columns.Bound(f => f.ProductorName).Width(350).Filterable(f => f.Operators(g => g.ForString(h => { h.Clear(); h.Contains("Conté"); })));
            columns.Bound(f => f.Poblacio).Filterable(f => f.Operators(g => g.ForString(h => { h.Clear(); h.Contains("Conté"); })));
            columns.ForeignKey(f => f.Reference, (System.Collections.IEnumerable)ViewBag.CatalegResidus, "Value", "Text");
            columns.Bound(f => f.Litres).HtmlAttributes(new { style = "text-align: right;" }).Width(60);
            columns.Bound(f => f.Kg).HtmlAttributes(new { style = "text-align: right;" }).Width(60);
            columns.ForeignKey(f => f.DestiID, (System.Collections.IEnumerable)ViewBag.Centres, "ContactID", "CodAutor").Width(80);
            columns.ForeignKey(f => f.StateID, (System.Collections.IEnumerable)ViewBag.ServiceStates, "OptionID", "Name").Width(100);
            columns.ForeignKey(f => f.OwnerID, (System.Collections.IEnumerable)ViewBag.Users, "PersonID", "Nom").Visible(false);
            if (User.IsInRole("Modify"))
            {
                columns.Command(commands =>
                {
                    commands.Edit();
                    commands.Destroy();
                }).Width(170);
            }
        })
        .Editable(e => e.Mode(GridEditMode.PopUp).TemplateName("CollectEdit"))
        .Events(e => e
            .Edit("service_onEdit")
        )
        .Pageable(pageable => pageable.Refresh(true))
        .Sortable()
        .Filterable()
        .DataSource(dataSource => dataSource
            .Ajax()
            .PageSize(18)
            .Model(m =>
            {
                m.Id(f => f.ServiceID);
                m.Field(f => f.OrderTypeID).DefaultValue((short)orderTypes.Recerca);
                m.Field(f => f.HolderID).DefaultValue(ViewBag.DefaultCentreID);
                m.Field(f => f.DestiID).DefaultValue(ViewBag.DefaultCentreID);
                m.Field(f => f.StateID).DefaultValue((short)serviceState.PdtPlan);
                m.Field(f => f.OwnerID).DefaultValue(ViewBag.Usuari);
            })
            .Events(e => e
                .Error(@<text> function (e) {onError(e, "collects");}</text>)
            )
            .Sort(s => s.Add(f => f.ServiceID).Descending())
            .Read("CollectRead", "Serveis")
            .Create("CollectCreate", "Serveis")
            .Update("CollectUpdate", "Serveis")
            .Destroy("CollectDestroy", "Serveis")
        )
    )

Template CollectEdit

@model SGIRO2014.Areas.Logistics.Models.CollectViewModel
 
<div class="container-fluid">
    <div class="row">
        <div class="form-horizontal col-md-12" style="width:905px">
            @Html.ValidationSummary(true, "", new { @class = "text-danger" })
            <div class="form-group">
                @Html.LabelFor(model => model.DataOrdre, new { @class = "col-md-1 control-label" })
                <div class="col-md-2">
                    @Html.EditorFor(model => model.DataOrdre)
                </div>
                @Html.LabelFor(model => model.Urgent, new { @class = "col-md-1 control-label col-md-offset-1" })
                <div class="col-md-1">
                    @Html.EditorFor(model => model.Urgent)
                </div>
                @Html.LabelFor(model => model.DataClaim, new { @class = "col-md-1 control-label" })
                <div class="col-md-2">
                    @Html.EditorFor(model => model.DataClaim)
                </div>
            </div>
 
            <div class="form-group">
                @Html.LabelFor(model => model.OrderTypeID, new { @class = "col-md-1 control-label" })
                <div class="col-md-3">
                    @Html.EditorFor(model => model.OrderTypeID)
                </div>
                @Html.LabelFor(model => model.HolderID, new { @class = "col-md-1 control-label" })
                <div class="col-md-2">
                    @Html.EditorFor(model => model.HolderID)
                </div>
            </div>
 
            <div class="form-group">
                @Html.LabelFor(model => model.DataServei, new { @class = "col-md-1 control-label" })
                <div class="col-md-2">
                    @Html.EditorFor(model => model.DataServei)
                </div>
                @Html.LabelFor(model => model.ExpeditionID, new { @class = "col-md-2 control-label" })
                <div class="col-md-2">
                    @Html.EditorFor(model => model.ExpeditionID)
                </div>
            </div>
 
            <div class="form-group">
                @Html.LabelFor(model => model.DocTypeID, new { @class = "col-md-1 control-label" })
                <div class="col-md-4">
                    @Html.EditorFor(model => model.DocTypeID)
                </div>
            </div>
 
            <div class="form-group">
                @Html.LabelFor(model => model.ProductorID, new { @class = "col-md-1 control-label" })
                <div class="col-md-5">
                    @Html.EditorFor(model => model.ProductorID)
                </div>
                @Html.LabelFor(model => model.DestiID, new { @class = "col-md-1 control-label" })
                <div class="col-md-2">
                    @Html.EditorFor(model => model.DestiID)
                </div>
            </div>
 
            <div class="form-group">
                @Html.LabelFor(model => model.Observacions, new { @class = "col-md-1 control-label" })
                <div class="col-md-9">
                    @Html.TextAreaFor(model => model.Observacions, new { @class = "form-control", @rows = 5 })
                </div>
            </div>
 
            <div class="form-group">
                @Html.LabelFor(model => model.Litres, new { @class = "col-md-1 control-label" })
                <div class="col-md-2">
                    @Html.EditorFor(model => model.Litres)
                </div>
                @Html.LabelFor(model => model.Kg, new { @class = "col-md-1 control-label" })
                <div class="col-md-2">
                    @Html.EditorFor(model => model.Kg)
                </div>
                @Html.LabelFor(model => model.Reference, new { @class = "col-md-1 control-label" })
                <div class="col-md-2">
                    @Html.EditorFor(model => model.Reference)
                </div>
            </div>
 
            <div class="form-group">
                @Html.LabelFor(model => model.Incidencies, new { @class = "col-md-1 control-label" })
                <div class="col-md-9">
                    @Html.TextAreaFor(model => model.Incidencies, new { @class = "form-control", @rows = 5 })
                </div>
            </div>
 
            <div class="form-group">
                @Html.LabelFor(model => model.OwnerID, new { @class = "col-md-1 control-label" })
                <div class="col-md-2">
                    @Html.EditorFor(model => model.OwnerID)
                </div>
                @Html.LabelFor(model => model.StateID, new { @class = "col-md-1 control-label" })
                <div class="col-md-2">
                    @Html.EditorFor(model => model.StateID)
                </div>
            </div>
        </div>
    </div>
</div>

I have @Html.EditorFor(model => model.ProductorID) in template. In model ProductID uses control [UIHint("ProductorSearch")]

@(Html.Kendo().ComboBoxFor(m => m)
    .Name("ProductorID")
    .HtmlAttributes(new { style = "width:400px" })
    //.AutoBind(false)
    //.Placeholder("Escriu...")
    .DataTextField("Description")
    .DataValueField("ContactID")
    .Filter(FilterType.Contains)
    .MinLength(4)
    .ValuePrimitive(true)
    .DataSource(source =>
    {
        source.Read(read => read.Action("SearchProductors", "Auxiliary", new { area = "" }).Data("filterProductors"))
            .ServerFiltering(true);
    })
    .Events(e => e
        .Change(onChange)
    )
    //.HeaderTemplateId("ProductorSearch_HeaderTemplate")
    //.TemplateId("ProductorSearch_ItemTemplate")
)

This control get data from function:

public async Task<JsonResult> SearchProductors(string textFilter, bool Actiu = true, bool allRoutes = false)
        {
            var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
            var rutesAutoritzades = user.AuthorizedRoutes.Split(',').ToList();
 
            var productors = ens.ProdCensus.Where(p => allRoutes || rutesAutoritzades.Contains("*") == true || rutesAutoritzades.Count(r => p.Ruta.Contains(r) == true) > 0).Select(p => new
            {
                ContactID = p.ContactID,
                Description = p.CodAutor + " - " + p.Nom + " - " + p.Poblacio,
                CodAutor = p.CodAutor,
                Nom = p.Nom,
                Poblacio = p.Poblacio,
                Baixa = p.Baixa
            });
 
            if (Actiu)
                productors = productors.Where(p => p.Baixa == null);
 
            if (!String.IsNullOrWhiteSpace(textFilter))
            {
                //productors = productors.Where(p => (p.CodAutor + " " + p.Nom).Contains(textFilter));
                productors = productors.Where(p => p.Description.Contains(textFilter));
            }
            else
                productors = null;
 
            return Json(productors, JsonRequestBehavior.AllowGet);
        }

Error: once when I edit on grid I get "ContactID" or "ProductID"  but I should get  "CodAutor" + "ProductName" + "Poblacio". I have attached two files.

 

 

 

0
Venelin
Telerik team
answered on 22 Feb 2016, 07:49 AM
Hello Xavier,

Basically .value() assigns to combobox what it has been passed as an argument to it. You stated that:
"On event edit from grid I get productor's data on combobox list. but I cannot assign this data to combobox value property.
From this, I cannot say what might be the problem with the .value() method, do you get any errors in the console?

Also you mentioned:
"Error: once when I edit on grid I get "ContactID" or "ProductID"  but I should get  "CodAutor" + "ProductName" + "Poblacio". 

Put a debugger/break point in the function you extract those values and see what data is returned.

Regards,
Venelin
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Xavier
Top achievements
Rank 1
answered on 22 Feb 2016, 04:26 PM

Hi again,

I find a post with same case (John Swenson had exactly the same case "http://www.telerik.com/forums/custom-combobox-column-editor-for-ajax-grid"), but I don't understand how to he found the solution.

Can you help me about this question?

 

Thanks in advance.

 

Xavier

 

 

 

0
Venelin
Telerik team
answered on 24 Feb 2016, 06:44 AM
Hi,

Have you checked the code-library that Peter Subev proposed: http://www.telerik.com/support/code-library/grid-editing-using-combobox-with-remote-binding-and-filtering ?

Unfortunately, the project John Swenson provided in this thread is no longer available for download. If the code library can't help resolving your problem I would advise you to send a very stripped version of your project with dummy data that I can run in order to observe the issue. In this manner we'll be close enough to your real scenario.
 
Regards,
Venelin
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Xavier
Top achievements
Rank 1
Answers by
Venelin
Telerik team
Xavier
Top achievements
Rank 1
Share this question
or