Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
173 views
Hi. I notice that if you input an incorrect date that the raddatepicker textbox highlights red with a yellow exclamation mark inside it. This is cool, especially when restricted for space. I have a requiredfieldvalidator that I would like to apply the same error to. Is there any way to call this from say javascript? Thanks.

Daniel
Daniel
Top achievements
Rank 1
Iron
Iron
Iron
 answered on 22 Jul 2010
1 answer
130 views
Hello,
I'm trying to use the panel bar for a site navigation and still be able to use custom attributes to specify properties for the panel bar such as ImageURL, HoverImageURL, etc but still have security trimming.
My first attempt was with a site map provider but I can't define custom attributes in the web.sitemap file.
Then I tried an xml file and then security trimming didn't work.

Is there anyway to use something other than the sitemapprovider and still have security trimming.

Thanks,
Brian
Brian Goldman
Top achievements
Rank 2
 answered on 22 Jul 2010
2 answers
367 views
Hi. What is the ClientEvents equivilant for OnClick for the RadTextBox? I can add it to the textbox itself and it works but VS gives me a warning saying the attribute isn't valid. As I said, the page still works okay, see code below. The function just clears the textbox when clicked in. Thanks.

Daniel

<telerik:RadTextBox ID="rtbLastname" runat="server" Skin="Default" Text="Last name" Width="99px" OnClick="if(this.value=='Last name')this.value='';"></telerik:RadTextBox>
Daniel
Top achievements
Rank 1
Iron
Iron
Iron
 answered on 21 Jul 2010
2 answers
159 views
Hi. I have several grids inside a multipage. The grids have scrolling enabled. I normally set all the columns to 1% with no wrapping and then set the column with the largest text in it to the remainder percentage. ie. 1%, 1%, 97%, 1%. This works fine with scrolling disabled. When I enable scrolling it looks like it is using the absolute size of 1% and is ignoring the text wrapping inside the header or column as all you can see is a pixel, probably the start of the text. This is a real pain, as some text looks really ugly when they wrap to the next line.

<telerik:RadGrid ID="rgActionRequests" runat="server" GridLines="None" OnNeedDataSource="rgActionRequests_OnNeedDataSource"
                                            AllowPaging="false" AllowSorting="false" Width="100%" BorderWidth="0">
                                            <MasterTableView AutoGenerateColumns="False" NoMasterRecordsText="<div style='padding: 10px;'>You have no action requests</div>">
                                                <Columns>
                                                    <telerik:GridTemplateColumn HeaderText="Request ID" UniqueName="ram_id" HeaderStyle-Width="1%"
                                                        ItemStyle-Width="1%" HeaderStyle-Wrap="false" ItemStyle-Wrap="false">
                                                        <ItemTemplate>
                                                            <a href="\\\\argus/Proclaim/CRM/PRODUCTION/crm<%#DataBinder.Eval(Container.DataItem, "ram_id")%>.vbs">
                                                                <%#DataBinder.Eval(Container.DataItem, "ram_id")%></a>
                                                        </ItemTemplate>
                                                    </telerik:GridTemplateColumn>
                                                    <telerik:GridBoundColumn DataField="descr" HeaderText="Details" UniqueName="descr"
                                                        HeaderStyle-Width="97%" ItemStyle-Width="97%">
                                                    </telerik:GridBoundColumn>
                                                    <telerik:GridBoundColumn DataField="date1" HeaderText="Received" UniqueName="date1"
                                                        HeaderStyle-Width="1%" ItemStyle-Width="1%" HeaderStyle-Wrap="false" ItemStyle-Wrap="false">
                                                    </telerik:GridBoundColumn>
                                                    <telerik:GridBoundColumn DataField="status" HeaderText="Status" UniqueName="status"
                                                        HeaderStyle-Width="1%" ItemStyle-Width="1%" HeaderStyle-Wrap="false" ItemStyle-Wrap="false">
                                                    </telerik:GridBoundColumn>
                                                </Columns>
                                            </MasterTableView><ClientSettings>
                                                <Scrolling UseStaticHeaders="true" AllowScroll="true" ScrollHeight="227px" SaveScrollPosition="true" />
                                            </ClientSettings>
                                        </telerik:RadGrid>

Something else I have noticed with scrolling and setting UseStaticHeaders to true, is that the line at the top of the scrollbar, between the scrollbar and header has been pushed up about 5 pixels. I have attached a screen of both issues. Thanks.

Daniel
Daniel
Top achievements
Rank 1
Iron
Iron
Iron
 answered on 21 Jul 2010
1 answer
133 views
I have a treeview and I want certain nodes to be checked when the page loads and some not checked. I want to do this manually before I loop through a database so was wondering if there is any VB.NET code out there that would show me.

I was thinking something like this (using objects):

Dim Cat As List(Of Category)
        Cat = Category.GetAllCategories
        If Not Cat Is Nothing Then

               Dim C As New RadTreeNode
                      Dim CatEach As Category
                           For Each CatEach In Cat
                                 C.Text = CatEach.Category
                                 C.Value = CStr(CatEach.catID)
                                  If C.Text = "Antiques" Then
                                   C.Checked = True
                                  End If
                                  RadTreeView1.Nodes.Add(C) 
                            Next
           End If

The treeview renders nicely but the "Antiques" checkbox remains unchecked. Any help here would be very much appreciated.
               
William
Top achievements
Rank 1
 answered on 21 Jul 2010
1 answer
129 views
Hello,

What I'm trying to do is essentially create a "Read-Only" combobox so the user can't make it dropdown or otherwise select anything.  I've prevented the dropdown, but they can still change it the value if they select it and then use the arrow keys to scroll down.  Is there a way to prevent this?
Gama
Top achievements
Rank 1
 answered on 21 Jul 2010
3 answers
229 views
                    <telerik:RadGrid ID="rgGrid" runat="server" AutoGenerateColumns="False" AllowAutomaticInserts="True"
                        AllowAutomaticDeletes="True" AllowAutomaticUpdates="True" DataSourceID="ldsProfiles"
                        GridLines="None" Skin="Office2007" BorderWidth="0px" OnItemCommand="rgGrid_ItemCommand"
                        OnItemUpdated="rgGrid_ItemUpdated" OnItemInserted="rgGrid_ItemInserted" OnItemCreated="rgGrid_ItemCreated"  >
                        <MasterTableView DataKeyNames="ProposalAttachmentID" DataSourceID="ldsProfiles"
                            EditMode="EditForms" CommandItemDisplay="Top" >
                            <CommandItemStyle CssClass="gridHeader" />
                            <CommandItemTemplate>
                                <div class="gridHeader">
                                    Files
                                </div>
                                  
                                <div class="sectionHeaderButton" style="margin-left: 10px;">
                                    <asp:LinkButton ID="rgProAddButton" runat="server" Text="(add)" CommandName="InitInsert" Visible='<%# 
  
!rgGrid.MasterTableView.IsItemInserted   %>' />
                                </div>
                                   
                            </CommandItemTemplate>
                            <Columns>
                                <telerik:GridBoundColumn DataField="UploadDate" DataType="System.DateTime" HeaderText="Date"
                                    ForceExtractValue="InEditMode" ReadOnly="true" SortExpression="UploadDate"
                                    UniqueName="UploadDate" DataFormatString="{0:MM/dd/yyyy}" ItemStyle-Width="13%">
<ItemStyle Width="13%"></ItemStyle>
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="User.FullName" DataType="System.String" HeaderText="Author"
                                    ForceExtractValue="InEditMode" ReadOnly="true" SortExpression="User.FirstName"
                                    UniqueName="User.FullName" ItemStyle-Width="15%">
<ItemStyle Width="15%"></ItemStyle>
                                </telerik:GridBoundColumn>
                                <telerik:GridTemplateColumn DataField="FileName" HeaderText="File" SortExpression="FileName"
                                    UniqueName="FileName" EditFormHeaderTextFormat="">
                                    <ItemTemplate>
                                                
                                        <asp:HyperLink ID="lbPorfiles" runat="server"  NavigateUrl='<%# UploadPath+"/"+Eval("ProposalFK")+"/"+ Eval("User.Login") 
  
+"/"+ Eval("FileName")%>' Target="_blank"  Text='<%# Bind("FileName")%>'></asp:HyperLink>
                                          
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <div style="left">
                                            <telerik:RadUpload ID="rdProfile" runat="server" InitialFileInputsCount="1"  
                                                MaxFileInputsCount="5" Localization-Add="Add More Files" EnableFileInputSkinning="true"
                                                ControlObjectsVisibility="AddButton" MaxFileSize="1000000" OnClientFileSelected="ValidateExtension"   
                                                AllowedFileExtensions=".doc,.pdf,.ppt,.xls" OnClientAdded="addTitle" Skin="Office2007" 
                                                Width="95%" InputSize="35">  
                                                <Localization Add="Add More Files" />
                                            </telerik:RadUpload>
                                            <span id="fileExtentionError" class="error" style="display:none; color:#cc0000; font-weight:bold">* Invalid file 
  
extensions. Only the following file formats can be uploaded: .doc,.pdf,.ppt,.xls</span> 
                                            <span id="nullDescriptionError" class="error" style="display:none; color:#cc0000; font-weight:bold">* Please enter 
  
Description</span> 
                                            <span id="overDescriptionError" class="error" style="display:none; color:#cc0000; font-weight:bold">* Please limit 
  
Description to 150 characters or less</span>                                                                                         
                                            <asp:CustomValidator Text="" runat="server" ID="FileUploadValidator" OnServerValidate="FileUpload_ServerValidate" 
  
ClientValidationFunction="ValidateFileUpload" />
                                            <%--        *Invalid file extensions. Only the following file formats can be uploaded: .doc,.pdf,.ppt,.xls
                                            </asp:CustomValidator> --%>                                                                                   
                                            <script type="text/javascript">
                                                function ValidateFileUpload(source, arguments)
                                                {
                                                    var radGrid = $find('<%= rgGrid.ClientID %>');
  
                                                    var radUpload = $telerik.findControl(radGrid.get_element(), "rdProfile");
  
                                                    var fileInputs = radUpload.getFileInputs()
                                                    var isValid = true;
  
  
                                                    //var descValue = $get('<%= rgGrid.ClientID %>' + 'Title' + i).value
                                                    var descValue = $get(radUpload.getID() + 'Title' + i).value                                                    
                                                      
                                                    //alert(descValue)
                                                    for (var i = 0; i < fileInputs.length; i++)
                                                    {
  
                                                    }
  
                                                    arguments.IsValid = isValid;
                                                }
                                                  
                                                var i = 0
                                                  
                                                function addTitle(sender, args)
                                                {
                                                    var inputRow = args.get_row();
                                                    var fileInputSpan = inputRow.getElementsByTagName("span")[0];
  
                                                    var tAddField = sender.getID("Title");
  
                                                    $(".ruInputs li[class='']:last span").after($("<textarea rows=3 cols='50'/>").attr("id", tAddField).attr("name", 
  
tAddField)).after($("<label class='fileInputLabel'>Description : </label>").attr("for", tAddField)).before($("<label class='fileInputLabel'>  File : 
  
</label>").attr("for", fileInputSpan));                                         
                                                }
  
                                            </script>
                                                                                           
                                        </div>
                                    </EditItemTemplate>
                                </telerik:GridTemplateColumn>
                        </MasterTableView>
                    </telerik:RadGrid>
I have a RadUpload control in EditTemplate inside a RadGrid.
I add the client code to add addtional field with TextArea type allowing user to enter comment for the uploading file.
And that additional comment field is a required field, also only 500 characters max limited.
I want a TextArea type because I want to user to see all the text they enter and input type=text just won't do the justification.
I seem to have a problem to get the addional field's value at client side code. 

I use  
   var radGrid = $find('<%= rgGrid.ClientID %>');

to get the grid control
and  
   var radUpload = $telerik.findControl(radGrid.get_element(), "rdProfile");
to get the upload control

When I try to retrive the value of the additional field by code similar to
   var descValue = $get(radUpload.getID() + 'Title' + i).value 
I am getting javascript error saying "object needed"

Anyone can help?
I attached my code

kevin yang
Top achievements
Rank 1
 answered on 21 Jul 2010
2 answers
300 views
Hi,

I have two DataTable objects that both contain the same data (first contains data before a certain change, second has the data after that change).

Assuming that both tables have the same number of records, is there any way to show differences between the tables in a nice, user-friendly way using Telerik RadGrid (or maybe any other Telerik control)?

Thanks,
Michael
Michael
Top achievements
Rank 1
 answered on 21 Jul 2010
1 answer
229 views
I have a simple FormTemplate that I am trying to grab the values from to perform an insert/update. I am trying to grab a Listbox to create a comma delimited list of the values that it contains. When I try to access it I get a null pointer. However, I can successfully access other controls in the same FormTemplate. Anyone have any ideas?

The control I am trying to access is the lstSelectedUsers control.

ASPX page:

<EditFormSettings EditFormType="Template" InsertCaption="Create new User Group" CaptionDataField="group_name" CaptionFormatString="Editing Group: <b>{0}</b>" PopUpSettings-Width="610px">
                            <FormTemplate>
                                <div style="padding-left:5px">
                                    <table border="0" cellpadding="2" cellspacing="0">
                                        <tr>
                                            <td>
                                                Name:
                                            </td>
                                            <td>
                                                <asp:TextBox runat="server" ID="GroupName" Text="<%# Bind('group_name') %>"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="vertical-align: top">
                                                Description:
                                            </td>
                                            <td>
                                                <asp:TextBox runat="server" ID="Description" Text="<%# Bind('description') %>" Wrap="true"
                                                    Width="300px" Height="35px" TextMode="MultiLine"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                Public:
                                            </td>
                                            <td>
                                                <asp:CheckBox ID="isPublic" runat="server" Checked='<%# (DataBinder.Eval(Container.DataItem,"is_public").ToString()!="0"?true:false) %>'
                                                    TabIndex="1" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                Users:
                                            </td>
                                            <td>
                                                <table cellpadding="0" cellspacing="0">
                                                    <tr class="LightBackground">
                                                        <td style="border: 1px solid gray;border-bottom:none;border-right:none;padding:3px"><b>Available</b></td>
                                                        <td style="border: 1px solid gray;border-bottom:none;border-left:none;padding:3px"><b>Selected</b></td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            <telerik:RadListBox runat="server" ID="lstAvailableUsers" AutoPostBackOnTransfer="false" Sort="Ascending" ButtonSettings-VerticalAlign="Middle" SelectionMode="Multiple" AllowTransfer="true" Width="240px" Height="150px" TransferMode="Move" AllowTransferOnDoubleClick="true" TransferToID="lstSelectedUsers" DataSourceID="dsAvailableUsers" DataKeyField="user_id" DataTextField="display_name"></telerik:RadListBox>
                                                        </td>
                                                        <td>
                                                            <telerik:RadListBox runat="server" ID="lstSelectedUsers" AutoPostBackOnTransfer="false" Sort="Ascending" Width="240px" Height="150px" SelectionMode="Multiple" AllowTransferOnDoubleClick="true" TransferToID="lstAvailableUsers"  DataSourceID="dsSelectedUsers" DataKeyField="user_id" DataTextField="display_name"></telerik:RadListBox>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                            </td>
                                            <td>
                                                <br />
                                                <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                                    runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                                                </asp:Button>&nbsp;
                                                <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                                    CommandName="Cancel"></asp:Button>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </FormTemplate>
                        </EditFormSettings>


************************ CodeBehind ************************************************************

protected void grdUserGroups_UpdateCommand(object source, GridCommandEventArgs e)
    {
        //Get the GridEditFormInsertItem of the RadGrid     
        GridEditFormItem item = (GridEditFormItem)e.Item;

        try
        {
            SqlConnection conn = Database.getConnection();

            String groupId = (item.KeyValues.Substring(11, item.KeyValues.Length - 13));

            string sql = "Update USER_GROUPS set group_name=@groupName, description=@description, is_public=@isPublic where group_id=@groupId";
            SqlCommand cmd = new SqlCommand(sql, conn);
            cmd.Parameters.AddWithValue("@groupName", (item.FindControl("groupName") as TextBox).Text);
            cmd.Parameters.AddWithValue("@description", (item.FindControl("description") as TextBox).Text);
            cmd.Parameters.AddWithValue("@isPublic", (item.FindControl("isPublic") as CheckBox).Checked ? "1" : "0");
            cmd.Parameters.AddWithValue("@groupId", groupId);
            cmd.ExecuteNonQuery();

********* THIS IS THE LINE THAT FAILS - The other FindControls up above work fine **************************************
            RadListBox lstSel = item.FindControl("lstSelectedUsers") as RadListBox;
            StringBuilder userIds = new StringBuilder();
            foreach (RadListBoxItem lstItem in lstSel.Items)
            {
                if (userIds.Length > 0)
                    userIds.Append(",");

                userIds.Append(lstItem.Value);
            }

            cmd = new SqlCommand("INSERT INTO USER_GROUP_MEMBERS (user_id, group_id) SELECT user_id, @groupId FROM users WHERE user_id in (" + userIds + ")", conn);
            cmd.Parameters.AddWithValue("@groupId", groupId);
            cmd.ExecuteNonQuery();

            conn.Close();
        }
        catch (Exception ex)
        { HandleGridStatus(ex, "inserted"); }
    }
Robert Bross
Top achievements
Rank 1
 answered on 21 Jul 2010
1 answer
935 views
Hi,

I'm adding a RadGrid to a page and am having issues getting my table data to display.

The grid is generally working, but every cell displays as 'system.data.datarowview' - looks like it's calling ToString() on the wrong object?

I am populating the grid entirely in code, but am declaring it statically in my ASPX.
I create the columns in the Page_Load method (when !IsPostback) - there is a variety of GridBoundColumns and GridHyperlinkColumns. The columns are instantiated, added to the grid.MasterTableView.Columns collection, and *then* have additional properties set.

When the time comes to populate the grid (during a partial postback event), I have a helper class that produces a DataTable object with columns with names that match the GridColumns in the grid.

I finally call Rebind() and set the DataSource of the grid to my DataTable in the NeedDataSource event.

When stepping through some of the events (I create a custom paging control), I can clearly see that my data is present in the DataSource, but it's not making it through to the grid.

If I set the grid to AutoGenerateColumns=true in my ASPX, I get duplicate columns, but the auto generated ones are displaying my cell data correctly.

I suspect I'm missing some step in wiring the DataTable columns to the GridColumns. Any advice?

Thanks,
Stefan
Stefan
Top achievements
Rank 1
 answered on 21 Jul 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?