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

Paging the Radgrid Problem

1 Answer 33 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vuyiswa
Top achievements
Rank 2
Vuyiswa asked on 02 Aug 2010, 01:06 PM
Good Day All

My Radgrid is defined as follows

<telerik:RadGrid ID="RadGrid1" 
                        AllowPaging="True" PageSize="5"
                runat="server" GridLines="None" Width="100%" OnItemCreated="RadGrid1_ItemCreated"
                OnItemCommand="RadGrid1_ItemCommand" Skin="Black">
                <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true" />
                <ItemStyle HorizontalAlign="Center" />
                                  
                  <MasterTableView>
                      <CommandItemSettings ExportToPdfText="Export to Pdf" />
                      <RowIndicatorColumn>
                          <HeaderStyle Width="20px" />
                      </RowIndicatorColumn>
                      <ExpandCollapseColumn>
                          <HeaderStyle Width="20px" />
                      </ExpandCollapseColumn>
                      <PagerStyle AlwaysVisible="True" />
                  </MasterTableView>
                                  
                <HeaderStyle HorizontalAlign="Center" />
                <AlternatingItemStyle HorizontalAlign="Center" />
            </telerik:RadGrid>

and i m getting data from XMl and i have a Function that returns the dataset and i am trying to do paging like this

//Paging
 private DataSet CreateDataSetFilterPaging(String Filter)
 {
 
     //Subject Filter
     string SubjectstrExpr = "SUBSTRING(DESCR,1,1) ='" + Filter + "'";
     //Staff Filter
     string StaffsstrExpr = "SUBSTRING(DESCR,1,1) ='" + Filter + "'";
 
     //Venue Filter
     string VenuestrExpr = "SUBSTRING(DESCR,1,1) ='" + Filter + "'";
     //Timetable Filter
     string TimetablestrExpr = "SUBSTRING(Code,1,1) ='" + Filter + "'";
 
     DataColumn[] keys = new DataColumn[1];
     DataSet dsFinalTimeTable = new DataSet();
     DataTable tbldt;
 
     tbldt = new DataTable("Subjects");
     //Add Staff Table
     XmlDataDocument xmlDatadocStaff = new XmlDataDocument();
     xmlDatadocStaff.DataSet.ReadXml(@"C:\Pilot Project\App_Data\Subjects.xml");
     tbldt = xmlDatadocStaff.DataSet.Tables["Subjects"];
     keys = new DataColumn[1];
     keys[0] = tbldt.Columns["ID"];
     tbldt.PrimaryKey = keys;
     DataView dvSubjects = tbldt.DefaultView;
     dvSubjects.RowFilter = StaffsstrExpr;
     DataTable tbldtFinal = dvSubjects.Table;
     dsFinalTimeTable.Tables.Add(tbldtFinal.Copy());
 
      
     //Add Venue Table
     tbldt = new DataTable("Venues");
     XmlDataDocument xmlDatadocVenue = new XmlDataDocument();
     xmlDatadocVenue.DataSet.ReadXml(@"C:\Pilot Project\App_Data\XML_Venue.xml");
     tbldt = xmlDatadocVenue.DataSet.Tables["VENUES"];
     keys = new DataColumn[1];
     keys[0] = tbldt.Columns["ID"];
     tbldt.PrimaryKey = keys;
     //DataView dvVenues = tbldt.DefaultView;
     //dvVenues.RowFilter = VenuestrExpr;
     //tbldt.Clear();
     //tbldt = dvVenues.Table;
     dsFinalTimeTable.Tables.Add(tbldt.Copy());
 
     //TimeTable
     tbldt = new DataTable("TimeTable");
     XmlDataDocument xmlDatadocTimeTable = new XmlDataDocument();
     xmlDatadocTimeTable.DataSet.ReadXml(@"C:\Pilot Project\App_Data\TimeTableFull.xml");
     tbldt = xmlDatadocTimeTable.DataSet.Tables[0];
     keys = new DataColumn[1];
     keys[0] = tbldt.Columns["ID"];
     tbldt.PrimaryKey = keys;
     DataView dvTimeTable = tbldt.DefaultView;
     dvTimeTable.RowFilter = TimetablestrExpr;
     DataTable tbldtfinaltime = dvTimeTable.Table;
     dsFinalTimeTable.Tables.Add(tbldtfinaltime.Copy());
 
     //Setup RelationsTimeTable//
     DataRelation VenuesRelations = new DataRelation("VenuesRel", dsFinalTimeTable.Tables["Appointment"].Columns["ID"], dsFinalTimeTable.Tables["Venues"].Columns["ID"]);
     DataRelation ModuleRelations = new DataRelation("SubjectRel", dsFinalTimeTable.Tables["Subjects"].Columns["ID"], dsFinalTimeTable.Tables["Appointment"].Columns["subjectid"]);
     dsFinalTimeTable.Relations.Add(VenuesRelations);
     dsFinalTimeTable.Relations.Add(ModuleRelations);
     return dsFinalTimeTable;
 }

and my ItemCreated Events looks like this

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
  {
 
 
      if (e.Item is GridPagerItem)
      {
          GridPagerItem pagerItem = (e.Item as GridPagerItem);
          pagerItem.PagerContentCell.Controls.Clear();
 
          for (int i = 65; i <= 65 + 25; i++)
          {
              LinkButton linkButton1 = new LinkButton();
              LiteralControl lc = new LiteralControl("  ");
 
              linkButton1.Text = "" + (char)i;
 
              linkButton1.CommandName = "alpha";
              linkButton1.CommandArgument = "" + (char)i;
 
              pagerItem.PagerContentCell.Controls.Add(linkButton1);
              pagerItem.PagerContentCell.Controls.Add(lc);
          }
 
          LiteralControl lcLast = new LiteralControl(" ");
          pagerItem.PagerContentCell.Controls.Add(lcLast);
 
          LinkButton linkButtonAll = new LinkButton();
          linkButtonAll.Text = "All";
          linkButtonAll.CommandName = "NoFilter";
          pagerItem.PagerContentCell.Controls.Add(linkButtonAll);
      }
 
  }

and my ItemCommand event looks like this

protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
  {
      String value = null;
      switch (e.CommandName)
      {
          case ("alpha"):
              {
                  value = string.Format("{0}", e.CommandArgument);
                  break;
              }
          case ("NoFilter"):
              {
                  value = "%";
                  break;
              }
      }
 
      RadGrid1.DataSource = CreateDataSetFilterPaging(value);
      RadGrid1.Rebind();
 
  }

and when a User clicks on alphabet it must filter the data according to the Filter. Now my Problem here is that even i select any Alphabet i still receive "A" Records , which will be a Default.  I am looking at the demo
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/alphabeticpaging/defaultcs.aspx


Thanks



1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 05 Aug 2010, 10:17 AM
Hi Vuyiswa,

I reviewed the code snippet, and it looks correct. If the problem persists, please open a formal support ticket and send us a small working project, demonstrating your full setup and showing the described issue. We will debug it locally and get back to you.

Thank you!

Regards,
Pavlina
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Vuyiswa
Top achievements
Rank 2
Answers by
Pavlina
Telerik team
Share this question
or