Telerik Forums
UI for ASP.NET AJAX Forum
0 answers
111 views
Hi,
I'm working on the batch update grid(http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/clienteditbatchupdates/defaultvb.aspx).

How do I stop the Update process if the validation fails?
Neelima
Top achievements
Rank 1
 asked on 03 Oct 2011
2 answers
67 views
Our RadGrid works fine in Firefox and IE but displays absurdly wide in Chrome. Its over 268 million pixels wide. It has occured on two of our pages now. Any idea why it is doing this and how to fix it.

Thanks,
Lonnie
<asp:ScriptManager runat="server" ID="ScriptManager1" />
    <div class="SearchTitle">Notes</div>
    <asp:Label runat="server" ID="lblStatus" /><br /><br />
    <telerik:RadGrid ID="gvSomeTable" runat="server" AllowSorting="True" AutoGenerateColumns="False" DataSourceID="dsSomeTable" AllowPaging="true" PageSize="25" AllowFilteringByColumn="true" ShowStatusBar="true">
        <ClientSettings Selecting-AllowRowSelect="true" EnableRowHoverStyle="true" EnablePostBackOnRowClick="true">
            <ClientEvents OnRowSelected="showNote" OnRowContextMenu="RowContextMenu" />
        </ClientSettings>   
        <MasterTableView DataKeyNames="someID" ClientDataKeyNames="someID" CommandItemDisplay="Top">
            <Columns>
                <telerik:GridDateTimeColumn DataField="startTime" HeaderText="Date of Event" SortExpression="startTime" />
                <telerik:GridBoundColumn DataField="CompName" HeaderText="Company" SortExpression="CompName">
                    <FilterTemplate>
                        <telerik:RadComboBox ID="cboCompany" Runat="server" Width="250px"
                            DataSourceID="dsCompanyList"
                            DataTextField="Company"
                            DataValueField="Company"
                            AllowCustomText="true"
                            MarkFirstMatch="true"
                            EmptyMessage="Filter by Company"
                            SelectedValue='<%# TryCast(Container,GridItem).OwnerTableView.GetColumn("CompanyName").CurrentFilterValue %>'
                            OnClientSelectedIndexChanged="CompanyIndexChanged" />
 
                        <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
                            <script type="text/javascript">
                                function CompanyIndexChanged(sender, args) {
                                    var tableView = $find("<%# TryCast(Container,GridItem).OwnerTableView.ClientID %>");
                                    tableView.filter("CompanyName", args.get_item().get_value(), "EqualTo");
                                }
                            </script>
                        </telerik:RadScriptBlock>
                    </FilterTemplate>
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="feederFundList" AllowFiltering="false" HeaderText="Fund" SortExpression="FundList">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="categoryList" AllowFiltering="false" HeaderText="Category" SortExpression="categoryList">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="AddedBy" HeaderText="By" SortExpression="AddedBy">
                    <FilterTemplate>
                        <telerik:RadComboBox ID="cboUserList" Runat="server" Width="250px"
                            DataSourceID="dsUserList"
                            DataTextField="AddedBy"
                            DataValueField="AddedBy"
                            AllowCustomText="true"
                            MarkFirstMatch="true"
                            EmptyMessage="Filter by User"
                            SelectedValue='<%# TryCast(Container,GridItem).OwnerTableView.GetColumn("AddedBy").CurrentFilterValue %>'
                            OnClientSelectedIndexChanged="userIndexChanged" />
 
                        <telerik:RadScriptBlock ID="RadScriptBlock3" runat="server">
                            <script type="text/javascript">
                                function userIndexChanged(sender, args) {
                                    var tableView = $find("<%# TryCast(Container,GridItem).OwnerTableView.ClientID %>");
                                    tableView.filter("AddedBy", args.get_item().get_value(), "EqualTo");
                                }
                            </script>
                        </telerik:RadScriptBlock>
                    </FilterTemplate>
                </telerik:GridBoundColumn>
                <telerik:GridDateTimeColumn DataField="AddedOn" HeaderText="On" SortExpression="AddedOn" />
                <telerik:GridHyperLinkColumn AllowFiltering="false" DataNavigateUrlFields="someID" DataNavigateUrlFormatString= "~/Events/somepage.aspx?someID={0}" Text="Edit" />
                <telerik:GridBoundColumn AllowFiltering="false"  DataField="dateRead" Visible="false" ReadOnly="true" />
            </Columns>
        </MasterTableView>     
    </telerik:RadGrid>
Lonnie
Top achievements
Rank 1
 answered on 03 Oct 2011
2 answers
94 views
Hi.
When I used List<object> type as datasource for self-reference hierarchy, I had a problem.
Here is my grid definition:
<telerik:RadGrid ID="RadGrid2" runat="server" DataSourceID="ObjectDataSource1"
            oncolumncreated="RadGrid2_ColumnCreated"
            onitemcreated="RadGrid2_ItemCreated"
            onitemdatabound="RadGrid2_ItemDataBound" CellSpacing="0" GridLines="None">
            <MasterTableView HierarchyLoadMode="Client" HierarchyDefaultExpanded="true"
                Width="100%"  AutoGenerateColumns="False" DataSourceID="ObjectDataSource1" DataKeyNames="ID, ParentID">
                <SelfHierarchySettings ParentKeyName="ParentID" KeyName="ID" />
                <Columns>
                    <telerik:GridBoundColumn DataField="ID" DataType="System.Int32"
                        FilterControlAltText="Filter ID column" HeaderText="ID" SortExpression="ID"
                        UniqueName="ID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ParentID" DataType="System.Int32"
                        FilterControlAltText="Filter ParentID column" HeaderText="ParentID"
                        SortExpression="ParentID" UniqueName="ParentID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Name"
                        FilterControlAltText="Filter Name column"
                        HeaderText="Name" SortExpression="Name"
                        UniqueName="Name">
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
            <ClientSettings AllowExpandCollapse="true" />
        </telerik:RadGrid>

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid2">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid2" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
        SelectMethod="GetAllTest"
        TypeName="BLL.Test">       
    </asp:ObjectDataSource>
    <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
    </telerik:RadScriptManager>

===============
Here is my code

    protected void Page_Load(object sender, EventArgs e)
    {      
        RadGrid2.MasterTableView.FilterExpression = @"it[""ParentID""] == 0";      
    }

    public void Page_PreRenderComplete(object sender, EventArgs e)
    {
        HideExpandColumnRecursive(RadGrid2.MasterTableView);
    }

    protected void RadGrid2_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        CreateExpandCollapseButton(e.Item, "ID");
        if (e.Item is GridHeaderItem && e.Item.OwnerTableView != RadGrid2.MasterTableView)
        {
            e.Item.Style["display"] = "none";
        }
        if (e.Item is GridNestedViewItem)
        {
            e.Item.Cells[0].Visible = false;
        }
    }

    protected void RadGrid2_ColumnCreated(object sender, Telerik.Web.UI.GridColumnCreatedEventArgs e)
    {
        if (e.Column is GridExpandColumn)
        {
            e.Column.Visible = false;
        }
        else if (e.Column is GridBoundColumn)
        {
            e.Column.HeaderStyle.Width = Unit.Pixel(100);
        }
    }

    public void HideExpandColumnRecursive(GridTableView tableView)
    {
        GridItem[] nestedViewItems = tableView.GetItems(GridItemType.NestedView);
        foreach (GridNestedViewItem nestedViewItem in nestedViewItems)
        {
            foreach (GridTableView nestedView in nestedViewItem.NestedTableViews)
            {
                nestedView.Style["border"] = "0";

                Button MyExpandCollapseButton = (Button)nestedView.ParentItem.FindControl("MyExpandCollapseButton");
                if (nestedView.Items.Count == 0)
                {
                    if (MyExpandCollapseButton != null)
                    {
                        MyExpandCollapseButton.Style["visibility"] = "hidden";
                    }
                    nestedViewItem.Visible = false;
                }
                else
                {
                    if (MyExpandCollapseButton != null)
                    {
                        MyExpandCollapseButton.Style.Remove("visibility");
                    }
                }

                if (nestedView.HasDetailTables)
                {
                    HideExpandColumnRecursive(nestedView);
                }
            }
        }
    }

    protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)
    {
        CreateExpandCollapseButton(e.Item, "ID");
    }

    public void CreateExpandCollapseButton(GridItem item, string columnUniqueName)
    {
        if (item is GridDataItem)
        {
            if (item.FindControl("MyExpandCollapseButton") == null)
            {
                Button button = new Button();
                button.Click += new EventHandler(button_Click);
                button.CommandName = "ExpandCollapse";
                button.CssClass = (item.Expanded) ? "rgCollapse" : "rgExpand";
                button.ID = "MyExpandCollapseButton";

                if (item.OwnerTableView.HierarchyLoadMode == GridChildLoadMode.Client)
                {
                    string script = String.Format(@"$find(""{0}"")._toggleExpand(this, event); return false;", item.Parent.Parent.ClientID);

                    button.OnClientClick = script;
                }

                int level = item.ItemIndexHierarchical.Split(':').Length - 1;

                button.Style["margin-left"] = level * 15 + "px";

                TableCell cell = ((GridDataItem)item)[columnUniqueName];
                cell.Controls.Add(button);
                cell.Controls.Add(new LiteralControl("&nbsp;"));
                cell.Controls.Add(new LiteralControl(((GridDataItem)item).GetDataKeyValue(columnUniqueName).ToString()));
            }
        }        
    }

    void button_Click(object sender, EventArgs e)
    {
        ((Button)sender).CssClass = (((Button)sender).CssClass == "rgExpand") ? "rgCollapse" : "rgExpand";
    }
==================
here is my BLL code

public class Test
    {
        private static readonly ITestDAL dal = DataAccess.CreateTestDAL();

        public static List<TestEntity> GetAllTest()
        {
            List<TestEntity> result = null;

            try
            {
                result = dal.GetAllTest();
            }
            catch (Exception ex)
            {
               .....
            }           

            return result;
        }
    }
==================
public class TestEntity
    {      
        private int id;
        private int parentID;
        private string name;

        public int ID
        {
            get { return this.id; }
            set { this.id = value; }
        }

        public int ParentID
        {
            get { return this.parentID; }
            set { this.parentID = value; }
        }

        public string Name
        {
            get { return this.name; }
            set { this.name = value; }
        }

        public TestEntity()
        {
        }

        public TestEntity(int id, int parentID, string name)
        {
            this.id = id;
            this.parentID = parentID;
            this.name = name;
        }

    }

==================
here is error message:
ExceptionType:Telerik.Web.UI.ParseException
ErrorMessage:No applicable indexer exists in type 'TestEntity'
ErrorSource:Telerik.Web.UI

==================
Can you please find the reason for the error ? Or , can you tell me how to realize self-reference hierarchy with List<Object> as datasource
David zhao
Top achievements
Rank 1
 answered on 03 Oct 2011
3 answers
66 views
Hi,
is there any way/documentation on how to deploy custom skin using stylebuilder for sharepoint 2010?

thank you.
Tsvetoslav
Telerik team
 answered on 03 Oct 2011
0 answers
116 views
Hi,

I'm having some issues with RadGrids created dynamically in the code behind. Here's an explanation of the situation:

I have a static RadGrid defined, let's call it "MainRadGrid", as well as a static formview below it. When I click on a row inside this radgrid, I fill out the formview with data depending on the row selected in the MainRadGrid. There's a RadAjaxPanel around these controls.

Some of the fields inside this formview are created dynamically. This includes several RadGrids that use their own ObjectDataSources with corresponding select, insert, and delete methods, as well as Automatic Inserts and Deletes enabled. Till now, everything is fine.

My page has an "Edit" button that puts the formview in edit mode. I click it, and everything goes into edit mode, including my dynamic radgrids (editmode = inplace, and all rows editable). All fine till now as well.

My issue occurs when I click on the "Add" button of the dynamic radgrids. At that point, I get an exception, which is the following:

Sys.WebForms.PageRequestManagerServerErrorException: Failed to load viewstate.  The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.  For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.

---
More explanations:
I catch the RowClicked command in the MainRadGrid_ItemCommand event. At that point, I retrieve a couple of values from the selected row and store them in the page's viewstate and then bind the formview.
I need these values to be able to load the correct data and dynamic fields into the formview. From my understanding, this is too late because the viewstate has already been loaded, which causes my issue mentioned above.

Any help with this issue?

---

I tried disabling the viewstate for my FormView. This fixes the issue mentioned above, but causes another one. Basically, the InitInsert command works fine when  I click on the "Add" button, but when I input values in the row generated then click on insert, the RadAjaxPanel mentioned earlier does its thing and the new row that was supposed to be added disappears instead, and the ObjectDataSource insert method is never called. The dynamically added RadGrid also goes back into readonly mode and does not take into consideration the EditIndexes.

So that's another issue.

---
To summarize:
1. I have a MainRadGrid and a FormView. I select a row in the RadGrid and databind the formview.
2. The formview creates dynamic controls depending on the row selected, including dynamic RadGrids that are connected to their own ObjectDatasources. This is done in the FormView_ItemCreated event.
3. I go into edit mode, and then attempt to add a new row to the dynamic RadGrids, and I get a viewstate error. If I disable the viewstate, the added row is there but when i click insert, the row disappears and the grid is not in edit mode anymore.

This is long, I know, but i hope you got this far. I will attempt to post sample code if possible.
blablabla
Top achievements
Rank 1
 asked on 03 Oct 2011
1 answer
154 views
I have change the style fot the rows + alt rows in the aspx not by CSS
but it is not working though I could change the grid header font and size but cant change its back color
in rows+ alt rows nothing only the horizontal alignment works nothing else working
what  am I doing wrong?

 

<HeaderStyle BackColor="#004000" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" Font-Size="XX-Small" ForeColor="Black" HorizontalAlign="Center" />

 

 

<ItemStyle BackColor="#E0E0E0" Font-Size="XX-Small" ForeColor="SpringGreen" HorizontalAlign="Center" />

 

 

<AlternatingItemStyle BackColor="Silver" Font-Bold="False" Font-Names="Arial" Font-Size="XX-Small"

 

 

ForeColor="RosyBrown" HorizontalAlign="Center" />

 


Ahmed
Pavlina
Telerik team
 answered on 03 Oct 2011
2 answers
111 views
I have a simple RadSplitter page with a variable number of panes; in each pane, a local ASPX page is rendered that shows a map of the UK with a graph of data overlaid on top.  The map is the same for every pane but the graphs of data vary: e.g., in the first pane I have data from 1983, in the second data from 1990, and so on.  I am constructing the RadSplitter (rsMaps) on the server like this:

// add a new pane (in the splitter) for each map
for (int i = 0; i < _numMaps; i++)
{  
    if (i > 0)
    {
        // add splitter-bars in between each map
        RadSplitBar rsb = new RadSplitBar();
        rsMaps.Items.Add(rsb);
    }
    RadPane rp = new RadPane();
    // set URL
    rp.ContentUrl = _mapUrlBase + Request.QueryString["URL" + i.ToString()] + "&MultiMap=true&Title=" + Request.QueryString["Title" + i.ToString()];
    rsMaps.Items.Add(rp);
}

So far so good -- the URL of each pane is read from the Request string (of the page containing the RadSplitter) and the content is subsequently loaded.  However, the data graphs are getting mixed up!  The results are random but generally what happens is that two of the panes will show the same graph (e.g. for 1983) and some graphs will not be shown at all (e.g. 1990).  I think this is because the panes are loaded simultaneously (in parallel) and that the page is becoming confused somehow.  Therefore I wanted to try loading the panes in sequence (so that one pane must have finished loading before the next one starts) rather than in parallel, to see if that might fix it.

My question, then, is as follows: Can I set the content URLs on the client and force the panes to load one at a time?  I was trying to do something like this, where the OnClientLoaded event of the RadSplitter is handled by the function below:

function LoadPanes(sender)
{
  var rsMaps = sender;
  var panes = rsMaps.getPanes();
  for (var i = 0; i < panes.length; i++)
  {
    var pane = panes[i];
    var contentUrl = getContentUrl(i); // this would come from the Request String
    pane.set_contentUrl(contentUrl);
    // >>>> PSEUDO-CODE: this is the bit I'd like to do <<<<
    while (!pane.HasFinishedLoading)
    {
       sleep(1000);
    }
  }
}

Any insights would be gratefully received!

Ed Graham
Ed
Top achievements
Rank 1
 answered on 03 Oct 2011
11 answers
153 views
Hi

I was here to find a solution for TimeZone when Server and client are at different locations.
The problem i am trying here to solve is that if I am in UK and Servers are in USA, then when i set a reminder to 5pm
it should popup reminder as per UK 5pm and not as per USA 5pm.

I guess there is a feature to manage this and when i tried to look at URL
http://demos.telerik.com/aspnet-ajax/scheduler/examples/timezones/defaultcs.aspx

It redirects me to http://demos.telerik.com/ErrorPageResources/error.aspx?aspxerrorpath=/aspnet-ajax/scheduler/examples/timezones/defaultcs.aspx

So I guess the link is not working.   Can anyone look into it.   and is there any other detail article/tutorial on the topic.

-JD
Peter
Telerik team
 answered on 03 Oct 2011
3 answers
77 views
I've got a treeview with checkable nodes. I'm trying to keep a count of how many are checked and I'm using the OnClientNodeChecking call to do so. Here is my function:

function UpdateTotal(sender, eventArgs) {
            var node = eventArgs.get_node();
            var pnode = node.get_parent();
 
            var attribs = pnode.get_attributes();
            var cnt = attribs.getAttribute("Count");
             
            if (!node.get_checked()) {
                cnt++;
            } else {
                cnt--;
            }
            attribs.setAttribute("Count", cnt);
//            var cnodes = pnode.get_nodes();
//            var cnt = 0;
//            for (var i = 0; i < cnodes.get_count(); i++) {
//                if (cnodes.getNode(i).get_checked()) {
//                    cnt++;
//                }
//            }
 
           pnode.set_text(attribs.getAttribute("DefaultName") + ' (' + cnt + ')');
        }

However, I noticed when I click the checkbox quickly, the event does not get called and therefore the counts are incorrect. Here is a video displaying the issue.

http://screencast.com/t/1FkFLNDk6

You'll notice when the screen first loads, the count is correct. If I click the checkbox, the count changes correctly. But if I double-click a checkbox, the count is not longer in sync. When the box is checked, it shows 4, when it's unchecked it shows 5, but it should be the other way around. I've also noticed that when I do a postback and check the state of the node in the code behind, it does not reflect what is being on the screen. Basically, the number that you see next to the parent node correctly corresponds to the number of nodes the treeview believes are checked when it gets to the code behind. However, what is displayed does not match with what the treeview actually thinks is checked.

Hopefully that makes sense,
Adam
Plamen
Telerik team
 answered on 03 Oct 2011
1 answer
65 views
Hi,  I am trying to design a function to delete a node from treeview by drag and drop.  I put the RadTreeview inside a panel with shaded background.  I created another trash panel next to it.  When I dragged the node into the trash panel, the server side node_drop event fired and everything was good.  However, what I really want is when I drag the node outside the shaded area, the server side node_drop event can be fired.  Is there a way to achieve that?

Thanks!
Tim
Plamen
Telerik team
 answered on 03 Oct 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?