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

[Solved] I am successfully changing the TEXT of the NoRecordsTemplate message with the NoRecordsTemplate : ITemplate class scenerio , but the "No records to display" message still appears when I blan

1 Answer 132 Views
Grid
This is a migrated thread and some comments may be shown as answers.
IQworks
Top achievements
Rank 1
IQworks asked on 25 Aug 2009, 10:39 PM
 Hi, 

     When there are no records to display, I get the correct message "No records to display".  However, when i display the insert/edit screen to enter new records, the message still appears on the bottom of the screen. This is fine.  But when i add a new record, I want
that message to go away. I understand that it would go away if I did a rebind after I entered the first record, but in my add data scenerio, i only rebind when I am done adding records and I am ready to redisplay the grid.
     To correct this, I saw a telerik post (http://www.telerik.com/community/forums/aspnet/grid/changing-no-records-to-display-text.aspx ) using the  a "NoRecordsTemplate : ITemplate" class. Now, my message of  "No Equipment to List as yet"    is used.  
1) Now when I add  that first record, I can blank out the message, BUT, instead of blank, the default "No records to display" appears. Am I missing another step ?
2)  Using that ITemplate class scenerio seems like a lot just to blank a message when a record is added. is thier a way to do this with 
less code (not that its a lot of code, but). 
3) I am populating and blanking out the   "No Equipment to List as yet"  message according to whether their was any data read in my needdatasource on the last rebind. I am doing this in my  ItemDataBound method, is this the right place to do it ?

Here is how I define the class
/* 090825b Need this class to emulate the NoRecordsTemplate   
     * so that we can control when and what message to display  
     * when no equipment records exist yet */  
    class iqNoRecordsTemplate : ITemplate  
        {  
 
        string iqText;  
        System.Drawing.Color iqColor;  
                  
       public iqNoRecordsTemplate(string text,System.Drawing.Color Color)  
            {  
             iqText=text;  
             iqColor = Color;  
            }  
          
        public void InstantiateIn(Control container)  
            {  
            Label lbl = new Label();  
            lbl.ID = "Label1";  
            lbl.Text = iqText;  
            lbl.ForeColor = iqColor;  
            container.Controls.Add(lbl);  
            }  
        }  
        


Here is how and where I change the text (equipmentGrid is my RadGrid)
   if (Session["AnyDataRead"] == "No") //090815a  
                {                  
                ftbox.Text = "0";  
                  
                // Create new No Records Template on the fly from iqNoRecordsTemplate()  
                // No records found messages.  
                   
                iqText = "No Equipment to List as yet"; // 090825b  
                equipmentGrid.MasterTableView.NoRecordsTemplate = new iqNoRecordsTemplate(iqText, System.Drawing.Color.Brown); // 090825b   
                }  
            else  
                {  
                ftbox.Text = equipmentGrid.PageSize.ToString();  
                iqText = " ";// 090825b  
                equipmentGrid.MasterTableView.NoRecordsTemplate = new iqNoRecordsTemplate(iqText, System.Drawing.Color.Brown); // 090825b   
                } 
When I initialize the iqText to " ", is when the default message seems to appear
(Ignore the passing of the System.DrawingColor.Brown while iqText gets the " ", it dosnt matter for now). 

    thanks for your help  

 

 

    

 

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 28 Aug 2009, 03:05 PM
Hello David,

Please test the attached demo that I created for you. Let me know whether it is suitable for your scenario.

Kind regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
IQworks
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or