Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
1.0K+ views
Hello,
I have a RadGrid (q2 2008)
The first column is template column with a textbox.

I want to iterate through all the rows and get the value of the textbox and perform an database action. How do I setup the iteration?

thanks!
prat
Top achievements
Rank 1
 answered on 04 Oct 2011
5 answers
202 views

I've been working on this issue all weeken and have read almost every post and demo related to the RadGrid and to the RadAjaxManager,  Hopefully I've posted enough informatio to get a clear understanding of my issue
I’m using a CommandItem Templete to add a new record to a grid with a custom form.  I have the “add new record” linkbutton working but I need some help with the grid refresh when the radWindow closes.  I'm using the sample that opens a radWindow and then passes back informtion to the parent form with the OnClientClose .  I’m also using DotNetNuke as my platform and I’ve creates a usercontrol for my module.  I would like the Grid to refresh when I close the radWindow that has the form.  I’m using the return to parent that is in one of the demos but I cannot get any type of grid refresh to work outside of calling a page reload.  It seems that the problem is in the fact that I need to programmatically add the radAjaxManager programmatically to the page.  I’ve tried using
Dim manager As New RadAjaxManager()
manager.ID = "RadAjaxManager1"
Me.Page.Form.Controls.Add(manager)

But if I try to immediately test it with
value = TryCast(Me.Page.Items(GetType(RadAjaxManager)), RadAjaxManager) I come back with nothing.

Also if I put

function refreshGrid(arg) {
                  if (!arg) {
                        var mgr = $find('<%=RadAjaxManager.GetCurrent(Page).ClientID %>');
                               mgr.ajaxRequest("Refresh")
                                return false;       
                    }
        }
I get this error:
A critical error has occurred.Object reference not set to an instance of an object.
I have added:
<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
 <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadGrid1">
           <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>

The bottom line is that I cannot get the RadAjaxManager1_AjaxRequest to fire so I can run   RadGrid1.MasterTableView.SortExpressions.Clear()
        RadGrid1.MasterTableView.GroupByExpressions.Clear()
        RadGrid1.Rebind()

I have added   window.location.reload(true); to the OnClientClose function and that refreshes the grid currently but that is not the smoothest way.  All help is appreciated.

Bill

William
Top achievements
Rank 1
 answered on 04 Oct 2011
4 answers
257 views
Hi,
My RadGrid not able to get back to display mode after user inser data.
This is the scenario
1). Have the command Name to InitInsert so that RadGrid enter insert data mode.
2).When user click button add ,it call command PerformInsert which in turn fire event RadGrid.InsertCommand.
3).User input is inserted to database and  RadGrid.Rebind() is called in order to refresh added data.
4).However the RadGrid is not able to go  back to display mode. There is 1 more addtional row there for user to key in their input.
Help Please!!


johnson lim
Top achievements
Rank 1
 answered on 04 Oct 2011
1 answer
93 views
Hello,

Our application is using a custom resource provider that fetches it's strings from a database.  Is there a way to either:

a) Have telerik ignore the custom provide and use it's own resource file
b) get a list of the resource keys and values so they can be duplicated in our database

A sample of what is being displayed is attached.  The "???" is the default string returned when the resource key is not found in the database.

Thank you.
Aisha Khurshid
Top achievements
Rank 1
 answered on 03 Oct 2011
4 answers
323 views
Hi All,
I have 2 level grid with MasterTableView and DetailTables. I am using ObjectDataSource to bind data to both of the master and detail tableview. I want to be able to access the rows (or DataItems) in detail table. I have the DetailTableDataBind event defined and which is being firing too. Unfortunately I can not enumerate through the list of Items as I'm getting empty Items list.
Please guide on how can I access the Items in DetatlTable. There is a DataBound event for the DetatlTableView which does nt seem much useful as its event argument is just regular System.EventAgrs. Is there any ItemDataBound event exist for the DetatlTableView ?
Any help on this ?

Thanks
Tejas
Top achievements
Rank 1
 answered on 03 Oct 2011
8 answers
628 views
I am having a problem with duplicate items in my listbox. I am using a RadListBox and a RadGrid. Each row in the grid has a checkbox and when the box is checked that item is added to the listbox with javascript (below.) After the user is done checking boxes they click a submit button and I am able to read the items from the list in the server side event handler.

The problem happens when the user changes pages on the grid. If they check 1 box from the first page and then go to the second page, the listbox will correctly show 1 item, but on the server side there will be 2 in the .Items collection. I added a breakpoint to the PreRender handler and found that the duplicate wasn't there yet. It is added after all the page is loaded, but I also added an alert box to the js below and it never fires on the second page of the grid. I can't figure out where the duplicate is coming from.

Any idea what's causing this?

function CheckChanged(sender, invoiceNumber) {  
    var listbox = $find("<%=lstInvoiceNoteEntry.ClientID %>");  
    if (sender.checked) {  
        var item = new Telerik.Web.UI.RadListBoxItem();  
        item.set_text(invoiceNumber);  
        listbox.trackChanges();  
        listbox.get_items().add(item);  
        listbox.commitChanges();  
    }  
    else {  
        var item = listbox.findItemByText(invoiceNumber);  
        listbox.trackChanges();  
        while (item) {  
            listbox.get_items().remove(item);  
            item = listbox.findItemByText(invoiceNumber);  
        }  
        listbox.commitChanges();  
    }  
}  
Anjali
Top achievements
Rank 1
 answered on 03 Oct 2011
0 answers
148 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
107 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
122 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
114 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
Narrow your results
Selected tags
Tags
+? more
Top users last month
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Dean
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Emil
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Dean
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Emil
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?