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

RadLiveTile does not display zero if spView is empty

0 Answers 38 Views
TileList
This is a migrated thread and some comments may be shown as answers.
Reeba
Top achievements
Rank 1
Reeba asked on 12 Jan 2015, 07:42 PM
I have 3 radlive tiles that are being updated by a webservice that gets the count from the sharepoint list.

My issue is if there are no items in the view I want to display zero in the tile. But for some reason it keeps bypassing the tile whose view is empty and goes to the next views.

I have tried if tbl!=null that does not work either. Looking for some suggestions that will make this work.

Web Service:

      public static int getView_Count(string viewname) //Returns the count for the view
        {

           //Get Values siteName/listName/viewName
            string siteName = null;
            string listName = null;
            string viewName = null;
            string[] temp = viewname.Split(';');

            foreach (string s in temp)
            {
                if (s.Contains("SiteName"))
                {
                    siteName = s.Substring(9);
                }
                else if(s.Contains("ListName"))
                {
                    listName = s.Substring(9);
                }
                else if (s.Contains("ViewName"))
                {
                    viewName = s.Substring(9);
                }
            }

            //Check SiteName null

            if (string.IsNullOrEmpty(siteName))
            {
                siteName = "0";

            }
           
            if(siteName!="0")
            {
           // SPSite mySite = SPContext.Current.Site;
            SPSite mySite=new SPSite(siteName);
            {
                using (SPWeb myWeb = mySite.OpenWeb())
                {
                   // SPList list_Probs = myWeb.Lists["Probs"];
                    SPList list_Probs = myWeb.Lists[listName];
                    DataTable tbl = new DataTable();

                    ////if (!string.IsNullOrEmpty(viewname))
                    //if (!string.IsNullOrEmpty(viewName))
                    //{
                        //SPView view_Probs = list_Probs.Views[viewname];
                        SPView view_Probs = list_Probs.Views[viewName]; //This is where it bypasses the view that has no value and goes on to the one that has a value

                        tbl = list_Probs.GetItems(view_Probs).GetDataTable();
                        myWeb.Dispose();
                        mySite.Close();
                        return tbl.Rows.Count;
                    }
                
            }
            }
                    else
                    {
                        //SPQuery PQuery = new SPQuery();
                        //PQuery.Query = "<Where><IsNull><FieldRef Name='AS400Date'/></IsNull></Where>";
                        //tbl = list_Probs.GetItems(PQuery).GetDataTable();
                        //myWeb.Dispose();
                        //return tbl.Rows.Count;
                        return 0;
                    }
            
                }

 Code Behind:

namespace DashboardCount.DashboardCount
{
    public partial class DashboardCountUserControl : UserControl
    {
        public DashboardCount DashboardCount { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            //Initialize the radlive tiles
            
            
            try
            {
                if (!string.IsNullOrEmpty(DashboardCount.Title ))
                {
                    lblTile.Text = DashboardCount.TitleWebPart;
                }
                else
                {
                    lblTile.Text = null;
                }
                lblExcep.Visible=false;
                InitializeTile(RadDash);
                InitializeTile(RadDash1);
                InitializeTile(RadDash3);
            }
            catch (Exception ex)
                {
                   lblExcep.Visible=true;
                lblExcep.Text=ex.Message;
                }
        }
        
        private void InitializeTile(RadLiveTile tile)
        {
           
                //tile.CssClass = "liveTile";
                string name = tile.ID;
                tile.Target = "_blank";
            

                //The text between the #= # characters is replaced by the corresponding properties of the data item
                //returned on the web service response.

                if (name == "RadDash")
                {
                    if (!string.IsNullOrEmpty(DashboardCount.Link1))
                    {
                        tile.NavigateUrl = DashboardCount.Link1;
                    }
                    tile.ClientTemplate = @"
                  <div style='width:170px;height:170px;background-color: #= GetColor #'> 
                <div style='text-align:center;font-size:60px;'><strong> #= ViewCount #</strong></div>  
                 <div style='text-align:center;font-size:18px;'><strong> #= GetTileName #</strong></div><br></br>                 
                 <div style='position:absolute;bottom:0;right:0;font-size:12px'> #=DDate  #</div>
                </div>";

                    tile.Value = "SiteName:" + DashboardCount.SiteName + ";ListName:" + DashboardCount.ListName + ";ViewName:" + DashboardCount.View1Name +";TileName:"+DashboardCount.Tile1Name +";MaxNormalCount:" + DashboardCount.MaxNormalCount1 + ";MaxWarningCount:" + DashboardCount.MaxWarningCount1 ; 
                }
                else if (name == "RadDash1")
                {
                    if (!string.IsNullOrEmpty(DashboardCount.Link2))
                    {
                        tile.NavigateUrl = DashboardCount.Link2;
                    }
                    tile.ClientTemplate = @"
                <div style='width:170px;height:170px;background-color:#= GetColor #'> 
                <div style='text-align:center;font-size:60px'><strong>#= ViewCount #</strong></div>  
                <div style='text-align:center;font-size:18px'><strong>#= GetTileName #</strong></div><br></br> 
                <div style='position:absolute;bottom:0;right:0;font-size:12px'> #=DDate  #</div>
                </div>";
                    tile.Value = "SiteName:" + DashboardCount.SiteName + ";ListName:" + DashboardCount.ListName + ";ViewName:" + DashboardCount.View2Name + ";TileName:" + DashboardCount.Tile2Name + ";MaxNormalCount:" + DashboardCount.MaxNormalCount2 + ";MaxWarningCount:" + DashboardCount.MaxWarningCount2; 
                }
                else if (name == "RadDash3")
                {
                    if (!string.IsNullOrEmpty(DashboardCount.Link3))
                    {
                        tile.NavigateUrl = DashboardCount.Link3;
                    }
                    tile.ClientTemplate = @"
                     <div style='width:170px;height:170px;background-color:#= GetColor #'> 
                     <div style='text-align:center;font-size:60px;'><strong>#= ViewCount #</strong></div> 
                    <div style='text-align:center;font-size:18px'><strong>#= GetTileName #</strong></div><br></br>                  
                    <div style='position:absolute;bottom:0;right:0;font-size:12px'> #=DDate  #</div>
                     </div>";
                    tile.Value = "SiteName:" + DashboardCount.SiteName + ";ListName:" + DashboardCount.ListName + ";ViewName:" + DashboardCount.View3Name + ";TileName:" + DashboardCount.Tile3Name + ";MaxNormalCount:" + DashboardCount.MaxNormalCount3 + ";MaxWarningCount:" + DashboardCount.MaxWarningCount3; 
                }
                //Configure the web service providing the live data.
                tile.WebServiceSettings.Path = "~/_layouts/DashboardWS/DashboardWS.asmx";
                tile.WebServiceSettings.Method = "GetEmpData";


                //Attach client side event handlers.
                tile.OnClientDataLoaded = "tileDataLoaded";
                tile.OnClientDataLoadingError = "tileDataLoadingError";
                //tile.OnClientTemplateDataBound = "tileClientTemplateDataBound";
            }

            
        }
    }



 

No answers yet. Maybe you can help?

Tags
TileList
Asked by
Reeba
Top achievements
Rank 1
Share this question
or