Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
229 views

Hi All,

I am using RadGrid in my application. I am fetching around 10 to 15 columns from the database and filling the RadGrid. As per the requirement, i have to display only specific columns in the Grid.

For this, I am hiding the columns from the user using javascript, which would not be displayed to the user.

I should also have to hide these columns in header context menu of RadGrid.

Can anyone please help to solve this issue?

Thanks,

KKB.

Shinu
Top achievements
Rank 2
 answered on 18 Jun 2009
4 answers
159 views
Hi,
I am using RadUpload for the first time. I want users to browse a file and click upload button. when the user clicks on upload button it should temporarily save that file in an array or a collection. After the user has uploaded all the files then he clicks on save button where it actually saves the all the uploaded files at once in a folder adn also in the database. Can anyone help me how to do this?
Thank you
John
Top achievements
Rank 2
 answered on 18 Jun 2009
1 answer
123 views
I am using PopUp Edit Mode in the grid and setting it as

Modal

 

="true"

However the entire window including the pop up window greys out.  Any one have a solution for this.

Thanks

 

Josh
Top achievements
Rank 1
 answered on 17 Jun 2009
1 answer
131 views
I really don't want to do postback, because we have a lot of controls created programmatically.
I see that through javascript I basically get the information I need:

 


function
OnClientDockPositionChanged(sender, args) {

 

alert(sender.get_dockZoneID());

alert(sender.get_uniqueID());

alert(sender.get_collapsed());

alert(sender.get_closed());

}

Do you have an example when the state of the docks is saved and loaded using web service call through AJAX's 

 

PageMethods?

Martin
Top achievements
Rank 1
 answered on 17 Jun 2009
2 answers
478 views
Hello,
     I am trying to build a RadTreeView with drag and drop functionality into a RadGrid. I have succeeded in building the grid and the tree and making all of the functionality work well. Every time a node is dragged to the grid, the node in the tree is given the color red to show the the item is currently in the grid (I've gotten the color change to work as well). The tree is currently working to show available attributes for a given item. The problem is, when the page loads, if there are currently attributes within the grid, I cannot make them change colors to red. I am using the Page Service (Example) method to generate all of my information with the tree, and I am also using a web service to generate the information in the grid. Is there a way to change the color of the nodes to red if the node has been pre-selected (such as if the attributes are saved and someone leaves the page and comes back the items will be in the grid)?

     Also, if an item is taken out of the grid, I am also having a hard time getting the color back to the black forecolor. I realize it's along the same line.
C# 
 
     [WebMethod] 
    public static RadTreeNodeData[] LoadNodes(RadTreeNodeData node) // called each time a node is expanded 
    { 
        AttributeService.Attribute atts = new AttributeService.Attribute(); 
        List<RadTreeNodeData> result = new List<RadTreeNodeData>(); 
        DataSet ds = new DataSet(), ads = new DataSet(); 
        DataTable data = new DataTable(), attributeData = new DataTable(); 
        int WebP_Id = Int32.Parse(HttpContext.Current.Session["WebPID"].ToString()); 
        ArrayList RadNodeChanged = new ArrayList(); 
 
        ds = atts.GetChildrenByWebpId(WebP_Id, Convert.ToInt32(node.Value)); // gets the children for a specific item 
        data = ds.Tables[0]; 
 
        foreach (DataRow row in data.Rows) 
        { 
            RadTreeNodeData childNode = new RadTreeNodeData(); 
 
            childNode.Text = row["AttributeName"].ToString(); // adds the name and the text to "childNode" 
            childNode.Value = row["Attribute_Id"].ToString(); 
 
            if (atts.GetAllChildren(Convert.ToInt32(childNode.Value)).Tables[0].Rows.Count > 0) 
            { 
                childNode.ExpandMode = TreeNodeExpandMode.WebService; 
            } 
            //can code go here to make the color of the node red when the parent is expanded? 
 
            //attributeData = atts.GetAttributes(WebP_Id).Tables[0]; 
            //foreach (DataRow dr in attributeData.Rows) 
            //{ 
            //    if (String.Compare(dr["AttributeId"].ToString(), childNode.Value) == 0) 
            //    { 
            //        childNode.Attributes["ForeColor"] = System.Drawing.Color.Red; 
            //    } 
            //}   //doesn't work 
 
            result.Add(childNode); 
        } 
        return result.ToArray(); 
    } 
 
    private static void LoadRootAttributeNodes(RadTreeView treeView, TreeNodeExpandMode expandMode) 
    {  
        AttributeService.Attribute attser = new AttributeService.Attribute(); // function is called to set the origin nodes 
        int WebP_Id = Int32.Parse(HttpContext.Current.Session["WebPID"].ToString());   
        DataSet ds = new DataSet(); 
        ArrayList Cat = new ArrayList(); 
        DataTable dt = new DataTable(); 
 
        ds = attser.GetChildrenByWebpId(WebP_Id, 0); // zero being for the high level parent nodes 
        dt = ds.Tables[0]; 
 
        foreach (DataRow row in dt.Rows) 
        { 
            RadTreeNode node = new RadTreeNode(); 
            node.Text = row["AttributeName"].ToString(); 
            node.Value = row["Attribute_Id"].ToString(); 
            node.ExpandMode = expandMode; 
            treeView.Nodes.Add(node); 
        } 
         
    } 
 
    protected void AttributesTree_HandleDrop(object sender, RadTreeNodeDragDropEventArgs e) 
    { //drag and drop function, when an item is released from the tree, this function will be called 
        RadTreeNode sourceNode = e.SourceDragNode, destNode = e.DestDragNode;         
        RadTreeViewDropPosition dropPosition = e.DropPosition; 
        AttributeService.Attribute atts = new AttributeService.Attribute(); 
        ArrayList deletedCat = new ArrayList(); 
        DataSet ds = new DataSet(); 
        DataTable dt = (DataTable)Session["AttributesTable"]; 
        bool existsInList = false; 
 
     
        Session["TreeView"] = AttributeTree; 
 
        foreach (GridDataItem dataItem in CurrentAttributesList.Items) 
        {             
            if (dataItem.ForeColor == System.Drawing.Color.Red) 
             {                
                deletedCat.Add(dataItem["AttributeId"].Text); 
            } 
        } 
         
        foreach (RadTreeNode node in e.DraggedNodes) 
        { 
            existsInList = false; 
            foreach ( GridDataItem item in CurrentAttributesList.Items ) 
            { 
                if (item["AttributeId"].Text == node.Value) 
                { 
                    existsInList = true; 
                } 
            } 
            if (existsInList) 
            { 
                Master.AttributePublishErrorMessage = "Please use an attribute that is not in the list"; // duplicate item 
            } 
            else 
            { 
                ds = atts.GetAttributeByAttributeID(Convert.ToInt32(node.Value)); 
                if (ds.Tables.Count > 0) 
                { 
                    foreach (DataRow dr in ds.Tables[0].Rows) 
                    { 
                        if (String.Compare(dr["Parent_ID"].ToString(), "0") == 0) 
                        { 
                            Master.AttributePublishErrorMessage = "Please use the lowest possible, non-parent attribute available."; 
                        } 
                        else 
                        { 
                            dt.Rows.Add(dr["Attribute_ID"], dr["AttributeName"], dr["AttributePath"]); 
                            foreach (RadTreeNode currentnode in AttributeTree.SelectedNodes) 
                            { 
                                currentnode.ForeColor = System.Drawing.Color.Red; 
                                RadTreeNodeChanged.Add(currentnode.Value);                                 
                            } 
                        } 
                    } 
                } 
            } 
        } 
 
        Session["AttributesTable"] = dt; 
        CurrentAttributesList.DataSource = dt; 
        CurrentAttributesList.DataBind(); 
 
        for (int i = 0; i < CurrentAttributesList.Items.Count; i++) 
        { 
            for (int j = 0; j < deletedCat.Count; j++) 
            { 
                if (CurrentAttributesList.Items[i]["AttributeId"].Text == deletedCat[j].ToString()) 
                { 
                    CurrentAttributesList.Items[i].Font.Strikeout = true; 
                    CurrentAttributesList.Items[i].ForeColor = System.Drawing.Color.Red; 
                } 
            } 
        } 
    } 
 
    public void CurrentAttributes(int webp_id) 
    { 
        AttributeService.Attribute atts = new AttributeService.Attribute(); 
        DataSet attributes = atts.GetAttributes(webp_id); 
        DataTable attributeData = attributes.Tables[0];         
        CurrentAttributesList.DataSource = attributeData; 
        CurrentAttributesList.DataBind(); 
        Session["AttributesTable"] = attributeData; 
    } 
    protected void CurrentAttributesList_Command(Object source, CommandEventArgs e) 
    { // the rad grid function when a command for save, delete, or refresh 
        int getWebP_Id = GetValidWebpId(SearchBox.Text), listIndex; 
        WebServiceProxy wsp = new WebServiceProxy(); 
        switch (e.CommandName) 
        { 
            case "SaveChanges": //when the command is save, the attribute will be saved to the database 
 
                AttributeService.Attribute atts = new AttributeService.Attribute(); 
                CategoryStatus attributeStatus, status; 
                currentAttributes = new ArrayList(); 
                DataSet CurrentAttributeList = atts.GetAttributes(getWebP_Id); 
                 
                //  load the current categories into a list, stores the status of each cat id 
                foreach (DataRow dataRowAttribute in CurrentAttributeList.Tables[0].Rows) 
                { 
                    attributeStatus.CatId = Convert.ToString(dataRowAttribute["AttributeId"]); 
                    attributeStatus.Status = 0; 
                    attributeStatus.Primary = false; 
 
                    currentAttributes.Add(attributeStatus); 
                } 
                // cycles through the rad grid to detect changes 
                foreach (GridDataItem dataItem in CurrentAttributesList.Items) 
                { 
                    string catid = dataItem["AttributeId"].Text; 
                    listIndex = FindInList(catid, currentAttributes); 
 
                    if (dataItem.ForeColor == System.Drawing.Color.Red) 
                    { 
                        updateListStatus(currentAttributes, ListStatus.Remove, listIndex); 
                    } 
 
                    if (listIndex < 0) //not in the list, needs to be added 
                    {                         
                        status.CatId = catid; 
                        status.Status = ListStatus.AddPrimary; 
                        status.Primary = false; 
                        currentAttributes.Add(status); 
                    } 
                    else 
                    { 
                        status = (CategoryStatus)currentAttributes[listIndex]; 
                    } 
                } 
                // stores the status of each cat id (add, remove, or no change) 
                foreach (CategoryStatus cs in currentAttributes) 
                { 
                    switch (cs.Status) 
                    { 
                        case ListStatus.NoChange: 
                            break; 
                        case ListStatus.AddPrimary: 
                            wsp.AddProductAttribute(getWebP_Id, Convert.ToInt32(cs.CatId), Request.ServerVariables["auth_user"], 0); 
                            break; 
                        case ListStatus.Remove: 
                            wsp.DeleteProductAttributes(getWebP_Id, Convert.ToInt32(cs.CatId)); 
                            break; 
                    } 
                } 
                CurrentAttributes(getWebP_Id); 
                 
 
            case "DeleteSelected": 
                // using a for loop to loop through each item, then set the selected ones to be red and struck through 
                // need to call a rebind instead of binding to a table to keep font attributes 
                for (int i = 0; i < CurrentAttributesList.Items.Count; i++) 
                { 
                    if (CurrentAttributesList.Items[i].Selected) 
                    { 
                        CurrentAttributesList.Items[i].Font.Strikeout = true; 
                        CurrentAttributesList.Items[i].ForeColor = System.Drawing.Color.Red; 
                    } 
                } 
 
                CurrentAttributesList.Rebind();                 
                break; 
            case "RebindGrid": // refresh grid back to original state, before any changes were made after hitting the save button 
                getWebP_Id = GetValidWebpId(SearchBox.Text); 
                CurrentAttributes(getWebP_Id); 
 
                foreach (string id in RadTreeNodeChanged) 
                { 
                    ControlItem node = AttributeTree.FindChildByValue <ControlItem> (id); 
                    node.ForeColor = System.Drawing.Color.Black; //doesn't work 
                } 
                break; 
            default: 
                break; 
        } 
    } 


ASPX: 
 
 
<asp:Content ID="CurrentAttributes" runat="server" ContentPlaceHolderID="AttributesRightContent"> 
    <asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
        <contenttemplate> 
            <telerik:RadGrid ID="CurrentAttributesList" runat="server" Skin="Vista" AllowMultiRowSelection="true" Height="448px" AllowPaging="true" PageSize="20" AllowAutomaticDeletes="true"> 
                <MasterTableView Width="100%" CommandItemDisplay="Top" DataKeyNames="AttributeID"> 
                      <CommandItemTemplate> 
                         <div style="padding: 5px 5px;"> 
                             <asp:LinkButton ID="btnSaveSelected" runat="server" CommandName="SaveChanges" OnCommand="CurrentAttributesList_Command"><img style="border:0px;vertical-align:middle;" alt="" src="Images/save.png" />&nbsp;Accept Changes</asp:LinkButton>&nbsp;&nbsp; 
                             <asp:LinkButton ID="btnDeleteSelected" OnClientClick="javascript:return confirm('Delete selected attributes?')" runat="server" CommandName="DeleteSelected" OnCommand="CurrentAttributesList_Command"><img style="border:0px;vertical-align:middle;" alt="" src="Images/Cancel.gif" />&nbsp;Delete selected customers</asp:LinkButton> &nbsp;&nbsp 
                             <asp:LinkButton ID="btnRefreshGrid" runat="server" CommandName="RebindGrid" OnCommand="CurrentAttributesList_Command"><img style="border:0px;vertical-align:middle;" alt="" src="Images/refresh.png" />&nbsp;Refresh attributes list to original</asp:LinkButton> 
                         </div> 
                      </CommandItemTemplate> 
                </MasterTableView> 
                <ClientSettings> 
                    <Selecting AllowRowSelect="true" EnableDragToSelectRows="true" /> 
                </ClientSettings> 
            </telerik:RadGrid> 
        </contenttemplate> 
    </asp:UpdatePanel> 
</asp:Content> 
<asp:Content ID="AttributesTree" runat="server" ContentPlaceHolderID="AttributesLeftContent"> 
    <asp:UpdatePanel id="AttributeUpdatePanel" runat="server" UpdateMode="Conditional"> 
        <contenttemplate> 
            <div class="DivAlignLeft"></div> 
            <div class="DivAlignRight"></div> 
            <telerik:RadTreeView ID="AttributeTree" runat="server" Skin="Vista" EnableDragAndDrop="true" 
                OnNodeDrop="AttributesTree_HandleDrop" OnClientNodeDropping="onNodeDropping" 
                OnClientNodeDragging="onNodeDragging" MultipleSelect="true"> 
                <WebServiceSettings Path="ProductsScreen.aspx" Method="LoadNodes" /> 
            </telerik:RadTreeView> 
        </contenttemplate> 
    </asp:UpdatePanel> 
</asp:Content> 


Any help would be greatly appreciated. Please let me know if there is anything else you need.

~~ Alex


Alex
Top achievements
Rank 2
 answered on 17 Jun 2009
2 answers
144 views
Hi,

To keep things simple I have stripped my problem down to the bare minimum. I have a basic TabStrip with 1 tab linking to a single PageView containing a single Grid.

I have followed the various threads on getting the height of the Grid to fill up the window. This works absolutely fine on its own. However as soon as I wrap it in the above TabStrip-MultiPage structure, the Paging section on the Grid overflows the window causing a scrollbar to display. Using IE8 developer tools, if I display:none the main RadTabStrip div the Grid fits fine in the window so I believe this is the culprit.

However my question is, how can I use the two controls together and keep the height 100% functionality on the Grid?

Regards,
Brett
Top achievements
Rank 1
 answered on 17 Jun 2009
7 answers
226 views
Is there a way to have the menu node on 2 lines, I've tried adding a <br/> between the words, it puts them on 2 lines but applies the styles to each line not as a whole.

Andy
Andy Green
Top achievements
Rank 2
 answered on 17 Jun 2009
2 answers
133 views
Hi All,

The asp.net ajax controls documentation has a great example of how to show a loading panel on initial page load. What would we have to do to have some text under the animated gif changing based on some server side work?

So it would look like.
[Loading.gif]
Loading frames...

then...
[Loading.gif]
Adding Layers...

then....
and finally showing the page.

Something like
 protected void RadAjaxManager1_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
        {
            if (e.Argument == "InitialPageLoad")
            {
  //simulate longer page load
                System.Threading.Thread.Sleep(2000);
                Label lbl = (Label)RadAjaxLoadingPanel1.FindControl("labelLoading");
                lbl.Text = "Adding Layers...";
                System.Threading.Thread.Sleep(2000);
                Panel2.Visible = true;

Is there a way to have the server send the new label text back to the client and have it refreshed? It looks like one can either poll from the client, or push from the server (reverse ajax) what's the Telerik way to accomplishing this?

Thanks!
JDT
Top achievements
Rank 1
 answered on 17 Jun 2009
3 answers
158 views
i have looked thru a number of posts, tried a lot of different things, and cannot get this to work. When I click on a menu item (say from the home page), it navigates to the selected screen. From that page, I want to change the background color of the menu item. I cannot do it from the .aspx using the cssclass, as one screen contains 2 menu items (for example, one screen on my website contains both 'Forms' and 'Links'). When 'Forms' is click, I want to highlight it in the menu and same for 'Links'. They both go to the same page.
I have tried both the following, but neither work. They are in my Page_Load.

 

<style type="text/css">

 

 

.selectedItem {

 

 

background-color: #FFD92F !important;

 

 

color: #000000 !important;

 

}

 

.rmItem { border-right: 1px solid white; }

 

 

.rmItem { border-top: 1px solid #7F8ECB; }

 

 

 

</style>

 




radmenu1.items(11).cssclass='SelectedItem'

AND 

 

Dim currentItem as Telerik.Web.UI.RadMenuItem

 

currentItem = radMenu1.FindItemByText(

"Forms")

 

currentItem.CssClass=

"SelectedItem"

Thanks,
Susan Pelzel

 

Atanas Korchev
Telerik team
 answered on 17 Jun 2009
0 answers
185 views
When attempting to save an appointment I get the following a NullReferenceException.

Call Stack

[NullReferenceException: Object reference not set to an instance of an object.]Telerik.Web.UI.AdvancedTemplate.get_Range() +1509Telerik.Web.UI.AdvancedTemplate.<CreateBasicControlsValidators>b__1(Object source, ServerValidateEventArgs args) +40System.Web.UI.WebControls.CustomValidator.OnServerValidate(String value) +140System.Web.UI.WebControls.CustomValidator.EvaluateIsValid() +113System.Web.UI.WebControls.BaseValidator.Validate() +72System.Web.UI.Page.Validate(String validationGroup) +8742012System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +8737174System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565


Example Code.

    public class QuoteRateProvider : Telerik.Web.UI.SchedulerProviderBase
    {




        /// <summary>
        /// Converts the quote day to appt data.
        /// </summary>
        /// <param name="rate">The rate.</param>
        /// <returns></returns>
        Appointment ConvertQuoteDayToApptData(QuoteRateDay rate)
        {
            Appointment data = new Appointment();
            data.Subject = rate.Description;
            data.Visible = true;
            data.Start = rate.StartDate;
            data.End = rate.EndDate;
            data.Attributes.Add("ManualRatePercentage", rate.ManualQuotePercentage.ToString());
            foreach (string cls in rate.AircraftClasses)
            {
                Resource r = new Resource("AircraftClass", cls, cls);
                data.Resources.Add(r);
            }
            data.ID = rate.ID;
            data.DataItem = rate;
            return data;
        }


        /// <summary>
        /// Converts the quote day to appt data.
        /// </summary>
        /// <param name="rates">The rates.</param>
        /// <returns></returns>
        List<Appointment> ConvertQuoteDayToApptData(IEnumerable<QuoteRateDay> rates)
        {
            List<Appointment> returnList = new List<Appointment>();
            foreach (QuoteRateDay rate in rates)
            {
                returnList.Add(ConvertQuoteDayToApptData(rate));
            }
            return returnList;

        }

        /// <summary>
        /// Converts the appt data to quote day rate.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <returns></returns>
        QuoteRateDay ConvertApptDataToQuoteDay(Appointment data)
        {
            QuoteRateDay rate = new QuoteRateDay();
            rate.Description = data.Subject;
            rate.StartDate = data.Start;
            rate.EndDate = data.End;
            rate.ManualQuotePercentage = Convert.ToDecimal(data.Attributes["ManualRatePercentage"]);
            rate.ID = Convert.ToInt32(data.ID);
            foreach (Resource r in data.Resources)
            {
                rate.AircraftClasses.Add(r.Text);
            }
            return rate;
        }



        /// <summary>
        /// Converts the quote days to appt data.
        /// </summary>
        /// <param name="rates">The rates.</param>
        /// <returns></returns>
        IEnumerable<Appointment> ConvertApptDataToQuoteDay(IEnumerable<QuoteRateDay> rates)
        {
            List<Appointment> data = new List<Appointment>();
            foreach (QuoteRateDay rate in rates)
            {
                data.Add(ConvertQuoteDayToApptData(rate));
            }
            return data;
        }



        public override void Delete(Telerik.Web.UI.RadScheduler owner, Telerik.Web.UI.Appointment appointmentToDelete)
        {
            QuoteRateDayDataAccess.DeleteDailyQuoteRate(Convert.ToInt32(appointmentToDelete.ID));
        }


        public override IEnumerable<Telerik.Web.UI.Appointment> GetAppointments(Telerik.Web.UI.RadScheduler owner)
        {
            return ConvertQuoteDayToApptData(QuoteRateDayDataAccess.GetQuoteRateDays(owner.VisibleRangeStart, owner.VisibleRangeEnd));
        }


        public override IEnumerable<Telerik.Web.UI.ResourceType> GetResourceTypes(Telerik.Web.UI.RadScheduler owner)
        {
            ResourceType t = new ResourceType("AircraftClass", true);
            
            List<ResourceType> rt = new List<ResourceType>();
            rt.Add(t);
            return rt;
        }

        public override IEnumerable<Telerik.Web.UI.Resource> GetResourcesByType(Telerik.Web.UI.RadScheduler owner, string resourceType)
        {
            List<Resource> rt = new List<Resource>();
            rt.Add(new Resource("AircraftClass", "HVY", "HVY"));
            rt.Add(new Resource("AircraftClass", "MID", "MID"));
            rt.Add(new Resource("AircraftClass", "LGT", "LGT"));

            return rt;
        }

        public override void Insert(Telerik.Web.UI.RadScheduler owner, Telerik.Web.UI.Appointment appointmentToInsert)
        {
            QuoteRateDayDataAccess.InsertDailyQuoteRate(ConvertApptDataToQuoteDay(appointmentToInsert));
        }

        public override void Update(Telerik.Web.UI.RadScheduler owner, Telerik.Web.UI.Appointment appointmentToUpdate)
        {
            QuoteRateDayDataAccess.UpdateDailyQuoteRate(ConvertApptDataToQuoteDay(appointmentToUpdate));
        }
    }
Ricky Jones
Top achievements
Rank 1
 asked on 17 Jun 2009
Narrow your results
Selected tags
Tags
+? more
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?