Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
485 views
I'm fetching column names and column types (Text, Note, DateTime, Number, and Currency) from another system in my c# code behind.

I use this to create a query to return back a datatable. I also use this to create columns for a RadGrid control my my ASPX page.

This is what I'm using to add fields to the grid:

private void AddFieldToRadGrid(string internalName, string type, string title)
        {
            if (rgStudyInfo.MasterTableView.Columns.FindByUniqueNameSafe(internalName) == null)
            {
                if (string.IsNullOrEmpty(title)) title = internalName;
                GridBoundColumn column = new GridBoundColumn();
                column.HeaderText = title;
                column.AllowSorting = true;
                column.AllowFiltering = true;
                column.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
                column.DataField = internalName;
                column.EmptyDataText = "N/A";
                column.UniqueName = internalName;
                column.SortExpression = internalName;
                column.ItemStyle.VerticalAlign = VerticalAlign.Top;
                Type typ;
                switch (type)
                {
                    case "DateTime":
                        typ = typeof(System.DateTime);
                        break;
                    case "Number":
                        typ = typeof(System.Int32);
                        break;
                    case "Currency":
                        typ = typeof(System.Decimal);
                        break;
                    default:
                        typ = typeof(System.String);
                        break;
                }
                column.DataType = typ;
                rgStudyInfo.MasterTableView.Columns.Add(column);
            }
        }

I read online that if the grid itself is delcared via markup, the new columns should be added during Page_Load within a !Page.IsPosback test. I can't get the dataformatstring to work if I add it here (using "{0:dd-MMM-yyyy}" for it in the case "DateTime" above). So I was attempting to format date fields during the itemdatabound event. But when I check to see if a field is type DateTime, I find that all fields are String. I checked if e.Item is GridDataItem, then instantiated a GridDataItem variable (e.Item as GridDataItem) to get the row.

The only place I found a referenced data type was in ((DataRowView)item.DataItem).Row.Table.Columns[col].DataType (col is an int index). And as I said, it's always System.String. Dates are in the columns, as strings that include date as well as time.

Also, since I programmatically added columns, do I need to do something special to handle sorting when users click column headers? When I click on them, the column headers' tex disappears and the grid isn't sorted.  Filtering breaks the page, but I haven't looked into that yet. Do I need to do something special for that since the columns were added programatically?

Data is loading fine during ItemDataBound event, and column headers are properly shown.


Pavlina
Telerik team
 answered on 17 Dec 2014
2 answers
120 views
I set the AllowPaging="true" and PageSize="2" but the list view only creates on long column when I was hoping it would create 2 columns.
Here is the code I have.

<telerik:RadListView ID="equipmentListView" runat="server" AllowPaging="true" PageSize="2">
    <LayoutTemplate>
        <div>
            <table>
                <tbody>
                    <tr id="itemPlaceholder" runat="server">
                    </tr>
                </tbody>
            </table>
        </div>
    </LayoutTemplate>
    <ItemTemplate>
        <tr>
            <td>
                <asp:Label ID="Label7" runat="server" Text="Stuff1" />
                <asp:Label ID="Label5" runat="server" Text="Stuff1" />
                <asp:Label ID="Label8" runat="server" Text="Stuff2" />
                <asp:Label ID="Label9" runat="server" Text="Stuff2" />
            </td>
        </tr>
    </ItemTemplate>
</telerik:RadListView>
James
Top achievements
Rank 1
 answered on 17 Dec 2014
3 answers
201 views
How do I change the width of  tool FontName and FontSize?
Ianko
Telerik team
 answered on 17 Dec 2014
4 answers
168 views
Hello,

I want to export scheduler to pdf with a specific format: header (logo and title) + content (the Scheduler) + footer (other information). I try to do it with atributte Stylesheets="Style.css", but it isn't work. Am I doing something wrong?, How can I have a customized pdf?

Thanks,
Regards,
Fer
Fernanda
Top achievements
Rank 1
 answered on 17 Dec 2014
1 answer
120 views
Hello,
   I am looking solution for script error in editor control but can't find anywhere.
The error come when the page are more than 200 and also the string content table format.
Please see attach file. I am using the Child page which use editor control Inherits from Master page which use ASP scriptmanager below:
<asp:ScriptManager ID="_ScriptManager" runat="server">
    </asp:ScriptManager>

The below control I use in design:
<telerik:RadEditor runat="server" ID="RTF1" EnableTextareaMode="false" Skin="Office2007"
                                    Width="99%" Height="500px" AutoResizeHeight="false" StripFormattingOptions="NoneSupressCleanMessage"
                                    ToolsFile="~/Include/XML/WordProcessorEditorTools.xml" OnClientSelectionChange="OnClientSelectionChange"
                                    OnClientLoad="OnClientEditorLoad" OnClientPasteHtml="OnClientPasteHtml">
                                    <CssFiles>
                                        <telerik:EditorCssFile Value="~/EditorContentArea.css" />
                                    </CssFiles>
                                    <SpellCheckSettings AllowAddCustom="true" />
                                    <ImageManager ViewPaths="~/medical_illustration" />
                                </telerik:RadEditor>

Please give me the solution.
I am helpless now because of this script error.
I hope you understand my problem and help me.
Thanks.
Ianko
Telerik team
 answered on 17 Dec 2014
2 answers
288 views
Hi,

Just for tests I put a button on my page and used the code below but it does not seem to cause  a postback of refetch of data using NeedDataSource in code-behind?

function refresh() {
    var masterTable = $find("<%= grdUsers.ClientID %>").get_masterTableView();
    masterTable.rebind();
}
Al
Top achievements
Rank 1
Iron
Iron
Iron
 answered on 17 Dec 2014
1 answer
128 views
When I upload a picture I want it to be scaled down to max width of 400px (according to scale) if a picture is about 1200px wide. How can I do that?
If an image is about 250 px, do nothing.
Kjell
Top achievements
Rank 1
Iron
Iron
 answered on 17 Dec 2014
1 answer
111 views
I have radgrid with custom telerik controls

i need to add  new row from client side




function AddRow(controlName, multirenlgon) {
 
            var grd = $('#' + controlName); // where controlName is the ID
        
            var tbod = grd[0].rows[0].parentNode;
            var newRow = grd[0].rows[grd[0].rows.length - 1].cloneNode(true);
            tbod.appendChild(newRow);
    
       
            var multi = multirenlgon;
         
            EnviaDato('Add', multi, '', '', '', '');
        }



everything is cloned and append but not Events


can you help me?
Konstantin Dikov
Telerik team
 answered on 17 Dec 2014
1 answer
194 views
Hi , 

i wanna help  
i exexute RadEditor tracking changes  , and as u know this feature in radeditor write at html code at the body of  RadEditor 
i wonder how i save the editor text without these changes , 

thanks , 
Marin Bratanov
Telerik team
 answered on 17 Dec 2014
1 answer
68 views
I am trying to use the RadPivotGrid control in my asp.net application (ajax control). But if there are no records to bind, how can i show the "No records found" message in this. ?
Maria Ilieva
Telerik team
 answered on 17 Dec 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?