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
75
Rowtemplate columns hidden
posted

Hi... how can I generate a rowtemplate with a column hidden? That column will have the PrimaryKey of the table.

 

My code is omething like this

@( Html.Infragistics().Grid<Feed>()
        .ID("grdFeeds")
        .UpdateUrl("EditingSaveChanges")
        .PrimaryKey("ID")
        .AutoGenerateColumns(false)
        .AutoCommit(true)
        .JQueryTemplating(true)
        .RowTemplate("<tr><td>${ID}</td><td>${Nombre}</td><td>${Letras}</td><td>${RutaIn}</td><td>${RutaOut}</td></tr>")
        .Columns(column => {
                                column.For(x => x.ID).HeaderText("ID").Hidden(true);
                                column.For(x => x.Nombre).HeaderText("Name");
                                column.For(x => x.Letras).HeaderText("Letters");
                                column.For(x => x.RutaIn).HeaderText("In Folder");
                                column.For(x => x.RutaOut).HeaderText("OutFolder");
                            }
                )
        .Features(features =>
        {           
            features.Filtering();   
            features.Paging().PageSize(20).PrevPageLabelText("Previous").NextPageLabelText("NEXT").ShowPageSizeDropDown(false).ShowPagerRecordsLabel(false);
            features.Selection().MouseDragSelect(true).MultipleSelection(true).Mode(SelectionMode.Row);
            features.Sorting().Mode(SortingMode.Single);
            features.Selection().Mode(SelectionMode.Row).MultipleSelection(false);
            features.Updating().EnableAddRow(false).EditMode(GridEditMode.None);
        
        })
        .DataSourceUrl(Url.Action("GetFeeds"))
        .Width("100%")
        .Height("500px")
        .DataBind()
        .Render()
    )      

 

but its rendering like

 

Thanks

Parents
No Data
Reply
  • 23953
    Suggested Answer
    Offline posted

    Hello,

    You can try to set display style to none for this column.

    Your row template string should look like this:

    Code Snippet
    1. RowTemplate("<tr><td style='display: none'>${ID}</td><td>${Nombre}</td><td>${Letras}</td><td>${RutaIn}</td><td>${RutaOut}</td></tr>")

    However this approach doesn't seem to work in Firefox(10.x.x).

    I assume that you want to use ID column in your code. If that is the case there is a better solution.

    When you set primaryKey property (PrimaryKey("ID")) igGrid adds "data-id" attribute to each row which value is set to the ID column value. ( Note: you don't need to define ID column in columns array.)

    Now you can get the ID value in jQuery like this:

    var id = $(row).attr("data-id"); where row is DOM element.

    The following code gets ID column for selected rows:

    Code Snippet
    1. function getSelectedRows() {
    2.     var rows = $('#grid1').igGridSelection('selectedRows');
    3.     $.each(rows, function (i, row) {
    4.         var rowId = $(row.element).attr("data-id");
    5.     });
    6. }

     

    Hope this helps,

    Martin Pavlov

    Infragistics, Inc.

Children
No Data