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

Grid and Sharepoint Web Parts

3 Answers 253 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tarique
Top achievements
Rank 1
Tarique asked on 08 Jan 2008, 08:49 PM
I am trying to build a very simple web part using your grid product.

Code is posted below.  Are there any good references you recommend for getting this to work.

using System;  
using System.Runtime.InteropServices;  
using System.Web.UI;  
using System.Web.UI.WebControls;  
using System.Web.UI.WebControls.WebParts;  
using System.Xml.Serialization;  
using System.Data;  
 
using Microsoft.SharePoint;  
using Microsoft.SharePoint.WebControls;  
using Microsoft.SharePoint.WebPartPages;  
 
 
using Telerik.Web.UI;  
 
using PmeUtilities;  
 
namespace PmeRisk  
{  
    [Guid("975f68de-868f-4e53-b5f4-1025a0db6c1c")]  
    public class RiskGrid : System.Web.UI.WebControls.WebParts.WebPart  
    {  
 
        private HtmlTextWriter textWriter;  
 
        private ScriptManager scriptMan;  
 
        public ScriptManager AtlasScriptManager  
        {  
            get  
            {  
                if (scriptMan == null)  
                {  
                    scriptMan = ScriptManager.GetCurrent(this.Page);  
                    if (scriptMan == null)  
                    {  
                        scriptMan = new ScriptManager();  
                        this.Controls.Add(scriptMan);  
                    }  
                }  
                return scriptMan;  
            }  
        }  
 
        public RiskGrid()  
        {  
            this.ExportMode = WebPartExportMode.All;  
        }  
        protected override void Render(HtmlTextWriter writer)  
        {  
            base.Render(writer);  
            textWriter = writer;  
        }  
 
 
        protected override void CreateChildControls()  
        {  
            base.CreateChildControls();  
            try  
            {  
 
                RadGrid radGrid = new RadGrid();  
                radGrid.ID = "RAD GRID";  
 
                String siteName = SharepointUtils.determineWebURL();  
                String riskListName = "Risks";  
 
                DataTable riskTable = SharepointUtils.getListItems(siteName, riskListName, textWriter);  
                radGrid.DataSource = riskTable.DefaultView;  
 
                  
 
                this.Controls.Add(radGrid);  
 
            }  
            catch (Exception ex)  
            {  
                String message = ex.Message;  
                String stackTrace = ex.StackTrace;  
 
            }  
 
 
        }  
    }  
}  
 

3 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 11 Jan 2008, 02:01 PM
Hi Tarique,

There are lots of clients which have implemented web parts based on RadControls.

Usually the most difficult thing is to set the RadControlsDir property to valid location because it is a bit tricky in SharePoint environment. Fortunately, with the Prometheus versions of our controls you do not need RadControls folder and this part becomes obsolete.

Creating a webpart based should be quite simple - here is a short sample:

public class MyWebPart : WebPart
{
     protected override void CreateChildControls()
     {
           base.CreateChildControls();

           RadGrid grid = new RadGrid();
           grid.ID = "myGrid";
           /* populate your grid based on your requirements */
           Controls.Add(grid);
     }

     protected override void RenderWebPart(HtmlTextWriter output)
     {
           EnsureChildControls();
           RenderChildren(output);
     }
}

Alternatively, you can try adding RadGrid on Init. For more info on building WebParts you can refer to msdn's articles such as Web Parts in Windows SharePoint Services .

Best regards,

Rosen
the Telerik team


Instantly find answers to your questions at the new Telerik Support Center
0
Tarique
Top achievements
Rank 1
answered on 14 Jan 2008, 05:14 PM
Hi Rosen,

I tried what you suggested with no luck.  Does the web.config need to be edited.  Are there any ajax specific instructions that need to be followed.

I added the following line to my web.config.  Please let me know if this is correct.

<

SafeControl Assembly="Telerik.Web.UI, Version=2007.3.1218.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.UI.Grid" TypeName="Grid" Safe="True" />

0
Rosen
Telerik team
answered on 17 Jan 2008, 09:01 AM
Hello Tarique,

You can refer to this blog post for more information on how to setup Sharepoint to use MS AJAX.

Sincerely yours,
Rosen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
Tarique
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Tarique
Top achievements
Rank 1
Share this question
or