Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
300
adding images and links
posted

How do you go about adding images and links to the grid.  We are using asp.net with json datasource.

Thanks

Sy

Parents Reply Children
  • 765
    Suggested Answer
    posted in reply to Martin Pavlov

    Thanks Martin.

    that's work!!

    this is the image of my igGrid:

    Then I leave the code used, with the features: Sorting, Filtering, Selection, Row Template, Paging, plus methods to obtain the value of the selected cell.

    @model IQueryable<CxcModels.Models.tblPaises>
    @using Infragistics.Web.Mvc;

    @{
        ViewBag.Title = "Catalogo de Pais";
        Layout = "~/Views/Shared/_Layout.cshtml";
    }
     <script type="text/javascript">

         function crear() {

             var adress = '@Url.Action("Create")';
             window.location = adress;
         }

         function editar() {

             var cell = $('#gridPaises').igGridSelection('selectedCell');
             var dataview = $('#gridPaises').data('igGrid').dataSource.dataView();
             if (cell == null) {
                 window.alert("Debe Seleccionar un renglon de la tabla.")
                 return;
             }
             var cellRowId = dataview[cell.rowIndex]["idPais"];
             var adress = '@Url.Action("Edit")' + "/" + cellRowId;
             window.location = adress;

         }
         function detalle() {

             var cell = $('#gridPaises').igGridSelection('selectedCell');
             var dataview = $('#gridPaises').data('igGrid').dataSource.dataView();
             if (cell == null) {
                 window.alert("Debe Seleccionar un renglon de la tabla.")
                 return;
             }
             var cellRowId = dataview[cell.rowIndex]["idPais"];
             var adress = '@Url.Action("Details")' + "/" + cellRowId;
             window.location = adress;

         }

         function eliminar() {

             var cell = $('#gridPaises').igGridSelection('selectedCell');
             var dataview = $('#gridPaises').data('igGrid').dataSource.dataView();
             if (cell == null) {
                 window.alert("Debe Seleccionar un renglon de la tabla.")
                 return;
             }
             var cellRowId = dataview[cell.rowIndex]["idPais"];
             var adress = '@Url.Action("Delete")' + "/" + cellRowId;
             window.location = adress;

         }
        
     </script>

    <h2>Catalogo de Pais</h2>
    @using (Html.BeginForm("Index", "Paises"))
    {
        <img alt="Agregar Pais" src="@Url.Content("~/Content/Iconos/AGREGARM.png")" onclick="crear()" />
        
        <br />
        <br />
       
        @(Html.Infragistics().Grid(Model).ID("gridPaises").AutoGenerateColumns(false).PrimaryKey("idPais").FixedHeaders(true).AutoGenerateLayouts(false)
        .JQueryTemplating(true)
        .RowTemplate("<tr><td><img alt='Editar' onclick='editar()' src='../../../../Content/Iconos/modificarTable.png' /></td><td><img alt='Detalle' onclick='detalle()' src='../../../../Content/Iconos/consultarTabla.png' /></td><td>${idPais}</td><td>${Nombre}</td></tr>")
        .Columns(column =>
        {
            column.For(x => x.idPais).HeaderText(" ").Width("30px").Column.Key = "Editar";
            column.For(x => x.idPais).HeaderText(" ").Width("30px").Column.Key = "Detalle";
            column.For(x => x.idPais).DataType("string").HeaderText("idPais").Width("380px");
            column.For(x => x.Nombre).DataType("string").HeaderText("Nombre").Width("430px");
        })
            .Features(features =>
            {
                features.Sorting().ColumnSettings(settings =>
                    {
                        settings.ColumnSetting().ColumnKey("Editar").AllowSorting(false);
                        settings.ColumnSetting().ColumnKey("Detalle").AllowSorting(false);
                        settings.ColumnSetting().ColumnKey("idPais").AllowSorting(true);
                        settings.ColumnSetting().ColumnKey("Nombre").AllowSorting(true);
                    });
                features.Selection().Mode(SelectionMode.Cell).MultipleSelection(false);
                features.Paging().PageSize(10).FirstPageLabelText("").FirstPageTooltip("Ir a primera pagina").PrevPageLabelText("").PrevPageTooltip("Ir a pagina Anterior").ShowPagerRecordsLabel(false)
                .LastPageLabelText("").LastPageTooltip("Ir a Ultima pagina").NextPageLabelText("").NextPageTooltip("Ir a Siguiente pagina").PageSizeDropDownLabel("Mostrar").PageSizeDropDownTrailingLabel("Registros");
                features.Filtering().FilterButtonLocation(Location.Left)
                    .ColumnSettings(settings =>
                    {
                        settings.ColumnSetting().ColumnKey("Editar").AllowFiltering(false);
                        settings.ColumnSetting().ColumnKey("Detalle").AllowFiltering(false);
                        settings.ColumnSetting().ColumnKey("idPais").AllowFiltering(true).FilterCondition("startsWith");
                        settings.ColumnSetting().ColumnKey("Nombre").AllowFiltering(true).FilterCondition("startsWith");
                    });
            })
        .Height("350")
        .DataSourceUrl(Url.Action("Index"))
        .DataBind().Render()
        )

    }

    I hope that helps somewhat!.

    Regards.

    Thanks Martin