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

Grouping with empty dataset

0 Answers 39 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Teseo
Top achievements
Rank 1
Teseo asked on 13 Oct 2011, 02:15 PM
Hi everyone,

Is it possible to define a grouping key either when the grid is empty?
I have to ajax bind the grid and I don't Know how many elements the grid will have.

The grid:
<% Html.Telerik()
                 .Grid(Model.RinnovoXBdg)
                 .DataKeys(keys =>
                 {
                      keys.Add(m => m.IdTestata);
                      keys.Add(m => m.IdTmpContratto);
                 })
                 .Name("Ricerca_CA")
                 .DataBinding(dataBinding => dataBinding
                         .Ajax()
                         .OperationMode(GridOperationMode.Client)
                         .Select("_Ajax_Contratti_Rinnovo", "Contratti"))
                 .Columns(columns =>
                 {
                      columns.Bound(d => d.IdTestata)
                                     .Title("Testata")
                                     .Sortable(false)
                                     .Width(50);
                      columns.Bound(d => d.IdTmpContratto)
                                     .Title("Selezionato")
                                     .Sortable(false)
                                     .Width(40);
                      columns.Bound(d => d.ProtocolloRinnovo)
                                     .Title("Protocollo")
                                     .Sortable(false)
                                     .Width(70);
                 })
                 .Groupable(grouping =>
                 {
                       grouping.Groups(
                                 groups => groups.Add(d => d.ProtocolloRinnovo));
                 })
                 .ClientEvents(events =>
                 {
                        events.OnDataBinding("RicercaCADataBinding");
                 })
                 .Scrollable(scrolling => scrolling.Height(300))
                 .Resizable(resizing => resizing.Columns(true))
                 .Pageable()
                 .Render(); %>
I have to group by ProtocolloRinnovo

Themethod in the controller is:
[GridAction]
public ActionResult _Ajax_Contratti_Rinnovo(Guid Guid)
{
      var contrattiRinnovabili = CManager.GetDettagliRinnovo(Guid);          
 
      return View(new GridModel(contrattiRinnovabili));
}

When my GridModel is empty I get a javaScript error cause the groupin key is an unidentified object.
How can I handle grouping if [contrattiRinnovabili] has no elements?
 

Q2 2011 (version 2011.2.712.0)
Tags
Grid
Asked by
Teseo
Top achievements
Rank 1
Share this question
or