1

I am using MVC Awsome grid, I want to hide first column of the grid, but struggling to do and no proper documentation for that in internet, please check below..

@(Html.Awe().Grid("MilkClassGrid").Load(false)
                            .CssClass("keynav")
                              .Columns(
        //new Column { Name = "Count", Width = 100, Header = "Count", ClientFormatFunc = "txtCount"},
                                  new Column { Name = "ID", Width = 100, Header = "", ClientFormatFunc = "txtslno" },
                                  new Column { Name = "MilkClasificatn", Width = 100, Header = "Classification", ClientFormatFunc = "txtClass" },
                                  new Column { Name = "MilkClassDesc", Width = 100, Header = "Description", ClientFormatFunc = "txtDesczzzz" }
        // new Column { Name = "Organic", ClientFormatFunc = "toggleButton", Width = 90}
                              )
                              .Url(@Url.Action("GetEmptyRecords"))
        //.PageSize(100)
                              .PageSize(5)
                              .Persistence(Persistence.Session)
                              .Persistence(Persistence.View) // save collapsed groups and nodes when switching between grid pages
                              .ColumnsPersistence(Persistence.Session) // save columns (width, grouping, etc..) for browser session lifetime
                              .Groupable(false)
        .Selectable(SelectionType.Single)
                              .Persistence(Persistence.View)
        //.Sortable(true)
                              .SendColumns(true)
                              .SingleColumnSort(true)
                              .Height(300)
                              .Parent("PageSize", "PageSize")
                              .Parent("MilkType", "search")
                              )

Edited

function txtslno(model, name) {

    var as = arryLen.length;
    as = parseInt(as) + parseInt(counta);
    var val = model[name];
    if (!val) val = "";
    if (as <= counta) {
        counta++;
        var html = "<input type='text' class='count11' disabled='disabled'  name='" + name + "' id='GetList_" + counta + "_slno'  value='" + escapeChars(val) + "'/>";

        return html;
    } else {
        return "<input type='text' class='count11' disabled='disabled'  name='" + name + "' id='GetList_" + as + "_slno1'  value='" + escapeChars(val) + "'/>";
    }
}

I have tried by calling a javascript function in Load function, but didn't getting, please help me anyone. Thank you

Omu
  • 69,856
  • 92
  • 277
  • 407
Developer
  • 876
  • 5
  • 18
  • 44

2 Answers2

0

Just inspect the page with chrome dev tools and hide the first row of the grid using css.

Similar to:

https://stackoverflow.com/a/30681422/769871

How to select first row of something with pure css:

Select only the first row in a table with css

Community
  • 1
  • 1
cchamberlain
  • 17,444
  • 7
  • 59
  • 72
0

If you only need the value that the first Column is showing there's no need to declare the column at all. The row model and what you are rendering in the grid row are separate things.

There's a demo for hiding columns here: https://demo.aspnetawesome.com/GridShowHideColumnsApiDemo

Basically it would be something like this:

var g = $('#Grid1');
g.data('o').columns[0].Hid = 1;
g.data('api').render() // or .load()
Omu
  • 69,856
  • 92
  • 277
  • 407