Telerik Forums
UI for ASP.NET AJAX Forum
10 answers
453 views
How can I set the grid to collapse it's groups on load via client side script.

I was previously doing this server side but I need to grid to stay expanded for people who have javascript disabled (the grid only collapses if the user has javascript on)

Vasil
Telerik team
 answered on 31 May 2013
5 answers
140 views
For those wanting to remove the default width on RadTextBoxes (or in my case RadNumericTextBoxes) you've probably come across this outdated solution. Here's the updated method that I used to solve this problem:
function RemoveWidth(sender, args) {
    sender.get_wrapperElement().style.removeProperty("width");
}

Attach this to the client OnLoad event and you should be good to go.

(I'll leave it up to Telerik to update the Code Library and/or correct my solution.)
Vasil
Telerik team
 answered on 31 May 2013
3 answers
111 views
I am receiving this error when i click on a radbutton when running my website in Azure, but it runs perfectly in the emulator.

[NullReferenceException: Object reference not set to an instance of an object.]
   System.Object.GetType() +0
   Telerik.Web.UI.RadCompression.Compress(HttpApplication application) +803
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +270

This error was gotten by using Fiddler...

Thoughts

Michael
Radoslav
Telerik team
 answered on 31 May 2013
1 answer
99 views
On this example, http://demos.telerik.com/aspnet-ajax/filter/examples/overview/defaultcs.aspx how can I make orderdate date only on filter, do not show the time filter, If I have a time filter, how to make the filter show time only?

Thanks!
Eyup
Telerik team
 answered on 31 May 2013
1 answer
63 views
How to get data items of nested grid(2nd level). I have to get all rows values on client side.
Princy
Top achievements
Rank 2
 answered on 31 May 2013
1 answer
88 views
Hi,

I am using a RadGrid with a HeaderContextMenu.  I would like to use a custom skin on the RadGrid (EnableEmbeddedSkins="false", Skin=""), but an embedded skin (Skin="Default") on the RadMenu/HeaderContextMenu.  How do I accomplish this?

Thanks,
Dave
Shinu
Top achievements
Rank 2
 answered on 31 May 2013
2 answers
103 views
Hello

I'm having trouble with a RadWindow, but first I want to quickly explain the order of the items that I have on the page.

Please see image001.png code corresponding to the following

<td colspan="6">
                   <telerik:RadTabStrip ID="tabInformation" runat="server" SelectedIndex="0" Width="100%"
                       MultiPageID="RadMultiPage1" CausesValidation="False" OnTabClick="tabInformation_TabClick">
                       <Tabs>
                           <telerik:RadTab runat="server" Text="Comentarios" Selected="True" PageViewID="Comments">
                           </telerik:RadTab>
                           <telerik:RadTab runat="server" Text="Teléfonos" PageViewID="Phones">
                           </telerik:RadTab>
                           <telerik:RadTab runat="server" Text="Direcciones" PageViewID="Address">
                           </telerik:RadTab>
                           <telerik:RadTab runat="server" Text="Correos Electrónicos" PageViewID="Emails">
                           </telerik:RadTab>
                       </Tabs>
                   </telerik:RadTabStrip>
                   <telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="0">
 
                       <telerik:RadPageView ID="RadPageView4" runat="server" Width="100%">
                           <telerik:RadTextBox ID="txtComments" runat="server" Height="100px" TextMode="MultiLine" Width="550px"></telerik:RadTextBox>
                       </telerik:RadPageView>
                       <telerik:RadPageView ID="RadPageView1" runat="server">
                           <telerik:RadToolBar ID="radPhones" runat="server" OnButtonClick="radPhones_ButtonClick">
                               <Items>
                                   <telerik:RadToolBarButton runat="server" CommandName="New" ImageUrl="~/Images/ToolBar/new.png"
                                       Text="Nuevo" CausesValidation="false">
                                   </telerik:RadToolBarButton>
                               </Items>
                           </telerik:RadToolBar>
                           <telerik:RadGrid ID="dtgPhones" runat="server" AutoGenerateColumns="False" CellSpacing="0" GridLines="None">
                               <ExportSettings>
                                   <Pdf PageWidth="" />
                               </ExportSettings>
                               <MasterTableView NoMasterRecordsText="No hay registros para mostrar.">
                                   <CommandItemSettings ExportToPdfText="Export to PDF" />
                                   <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True"></RowIndicatorColumn>
                                   <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True"></ExpandCollapseColumn>
                                   <Columns>
                                       <telerik:GridBoundColumn DataField="PHONE_ID" FilterControlAltText="Filter PHONE_ID column" HeaderText="ID" UniqueName="PHONE_ID" Visible="false"></telerik:GridBoundColumn>
                                       <telerik:GridBoundColumn DataField="PERSON_ID" FilterControlAltText="Filter PERSON_ID column" HeaderText="ID_PERSON" UniqueName="PERSON_ID" Visible="false"></telerik:GridBoundColumn>
                                       <telerik:GridBoundColumn DataField="INDICATIVE" FilterControlAltText="Filter INDICATIVE column" HeaderText="Indicativo" UniqueName="INDICATIVE"></telerik:GridBoundColumn>
                                       <telerik:GridBoundColumn DataField="PHONE" FilterControlAltText="Filter NUMERO column" HeaderText="Número" UniqueName="NUMERO"></telerik:GridBoundColumn>
                                       <telerik:GridBoundColumn DataField="EXTENSION" FilterControlAltText="Filter EXTENSION column" HeaderText="Ext." UniqueName="EXTENSION"></telerik:GridBoundColumn>
                                       <telerik:GridBoundColumn DataField="TYPE_DESCRIPTION" FilterControlAltText="Filter TYPE_DESCRIPTION column" HeaderText="Tipo" UniqueName="TYPE_DESCRIPTION"></telerik:GridBoundColumn>
                                       <telerik:GridBoundColumn DataField="TYPE" FilterControlAltText="Filter TYPE column" HeaderText="Tipo" UniqueName="TYPE" Visible="False">
                                       </telerik:GridBoundColumn>
                                       <telerik:GridCheckBoxColumn DataField="PRINCIPAL" FilterControlAltText="Filter PRINCIPAL column" HeaderText="Principal" UniqueName="PRINCIPAL">
                                           <HeaderStyle HorizontalAlign="Center" />
                                           <ItemStyle HorizontalAlign="Center" />
                                       </telerik:GridCheckBoxColumn>
                                       <telerik:GridCheckBoxColumn DataField="ACTIVE" FilterControlAltText="Filter ACTIVE column" HeaderText="Active" UniqueName="ACTIVE">
                                           <HeaderStyle HorizontalAlign="Center" />
                                           <ItemStyle HorizontalAlign="Center" />
                                       </telerik:GridCheckBoxColumn>
                                   </Columns>
                                   <PagerStyle PageSizeControlType="RadComboBox" />
                               </MasterTableView><PagerStyle PageSizeControlType="RadComboBox" />
                               <FilterMenu EnableImageSprites="False"></FilterMenu>
                           </telerik:RadGrid>
                       </telerik:RadPageView>
 
                       <telerik:RadPageView ID="RadPageView2" runat="server">
                           <telerik:RadGrid ID="dtgAddress" runat="server" AutoGenerateColumns="False" CellSpacing="0" GridLines="None">
                               <ExportSettings>
                                   <Pdf PageWidth="" />
                               </ExportSettings>
                               <MasterTableView NoMasterRecordsText="No hay registros para mostrar.">
                                   <CommandItemSettings ExportToPdfText="Export to PDF" />
                                   <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True">
                                       <HeaderStyle Width="20px" />
                                   </RowIndicatorColumn>
                                   <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True">
                                       <HeaderStyle Width="20px" />
                                   </ExpandCollapseColumn>
                                   <Columns>
                                       <telerik:GridBoundColumn DataField="ADDRESS_ID" FilterControlAltText="Filter ADDRESS_ID column" HeaderText="ID" UniqueName="ADDRESS_ID" Visible="false"></telerik:GridBoundColumn>
                                       <telerik:GridBoundColumn DataField="PERSON_ID" FilterControlAltText="Filter PERSON_ID column" HeaderText="PersonID" UniqueName="PERSON_ID" Visible="false"></telerik:GridBoundColumn>
                                       <telerik:GridBoundColumn DataField="ADDRESS" FilterControlAltText="Filter ADDRESS column" HeaderText="Dirección" UniqueName="ADDRESS"></telerik:GridBoundColumn>
                                       <telerik:GridBoundColumn DataField="TYPE" FilterControlAltText="Filter TYPE column" HeaderText="Tipo" UniqueName="TYPE" Visible="false"></telerik:GridBoundColumn>
                                       <telerik:GridBoundColumn DataField="TYPE_DESCRIPTION" FilterControlAltText="Filter TYPE_DESCRIPTION column" HeaderText="Tipo" UniqueName="TYPE_DESCRIPTION"></telerik:GridBoundColumn>
                                       <telerik:GridCheckBoxColumn DataField="PRINCIPAL" FilterControlAltText="Filter PRINCIPAL column" HeaderText="Principal" UniqueName="PRINCIPAL">
                                           <HeaderStyle HorizontalAlign="Center" />
                                           <ItemStyle HorizontalAlign="Center" />
                                       </telerik:GridCheckBoxColumn>
                                       <telerik:GridCheckBoxColumn DataField="ACTIVE" FilterControlAltText="Filter ACTIVE column" HeaderText="Active" UniqueName="ACTIVE">
                                           <HeaderStyle HorizontalAlign="Center" />
                                           <ItemStyle HorizontalAlign="Center" />
                                       </telerik:GridCheckBoxColumn>
                                   </Columns>
                                   <PagerStyle PageSizeControlType="RadComboBox" />
                               </MasterTableView>
                               <PagerStyle PageSizeControlType="RadComboBox" />
                               <FilterMenu EnableImageSprites="False">
                               </FilterMenu>
                           </telerik:RadGrid>
                       </telerik:RadPageView>
                       <telerik:RadPageView ID="RadPageView3" runat="server">
                           <telerik:RadGrid ID="dtgEmails" runat="server" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AutoGenerateColumns="False" CellSpacing="0" GridLines="None">
                               <ExportSettings>
                                   <Pdf PageWidth="" />
                               </ExportSettings>
                               <MasterTableView NoMasterRecordsText="No hay registros para mostrar.">
                                   <CommandItemSettings ExportToPdfText="Export to PDF" />
                                   <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True">
                                       <HeaderStyle Width="20px" />
                                   </RowIndicatorColumn>
                                   <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True">
                                       <HeaderStyle Width="20px" />
                                   </ExpandCollapseColumn>
                                   <Columns>
                                       <telerik:GridBoundColumn DataField="MAIL_ID" FilterControlAltText="Filter MAIL_ID column" HeaderText="ID" UniqueName="MAIL_ID" Visible="false"></telerik:GridBoundColumn>
                                       <telerik:GridBoundColumn DataField="PERSON_ID" FilterControlAltText="Filter PERSON_ID column" HeaderText="PersonID" UniqueName="PERSON_ID" Visible="false"></telerik:GridBoundColumn>
                                       <telerik:GridBoundColumn DataField="EMAIL" FilterControlAltText="Filter EMAIL column" HeaderText="Correo" UniqueName="EMAIL"></telerik:GridBoundColumn>
                                       <telerik:GridBoundColumn DataField="TYPE" FilterControlAltText="Filter TYPE column" HeaderText="Tipo" UniqueName="TYPE" Visible="false"></telerik:GridBoundColumn>
                                       <telerik:GridBoundColumn DataField="TYPE_DESCRIPTION" FilterControlAltText="Filter TYPE_DESCRIPTION column" HeaderText="Tipo" UniqueName="TYPE_DESCRIPTION"></telerik:GridBoundColumn>
                                       <telerik:GridCheckBoxColumn DataField="PRINCIPAL" FilterControlAltText="Filter PRINCIPAL column" HeaderText="Principal" UniqueName="PRINCIPAL">
                                           <HeaderStyle HorizontalAlign="Center" />
                                           <ItemStyle HorizontalAlign="Center" />
                                       </telerik:GridCheckBoxColumn>
                                       <telerik:GridCheckBoxColumn DataField="ACTIVE" FilterControlAltText="Filter ACTIVE column" HeaderText="Active" UniqueName="ACTIVE">
                                           <HeaderStyle HorizontalAlign="Center" />
                                           <ItemStyle HorizontalAlign="Center" />
                                       </telerik:GridCheckBoxColumn>
                                   </Columns>
                                   <EditFormSettings>
                                       <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                                       </EditColumn>
                                   </EditFormSettings>
                                   <PagerStyle PageSizeControlType="RadComboBox" />
                               </MasterTableView>
                               <PagerStyle PageSizeControlType="RadComboBox" />
                               <FilterMenu EnableImageSprites="False">
                               </FilterMenu>
                           </telerik:RadGrid>
                       </telerik:RadPageView>
 
                   </telerik:RadMultiPage>
                   <telerik:RadWindowManager ID="RadWindowEditors" runat="server" Behaviors="Resize, Close, Move" VisibleStatusbar="False"></telerik:RadWindowManager>
               </td>

This is the problem
You can navigate the tabs without problems, but if the user is in the tab "Telefonos" and press the button Nuevo (New) shows the window see imagen002.png, the user can save or close and the window disappears, but when switching between tabs, the window reappears, as if the user would click on the button again.

The code of the Nuevo (New) button is as follows:

RadWindowEditors.Modal = true;
RadWindowEditors.CenterIfModal = true;
 
string url = string.Format("PersonsPhonesEditor.aspx?action=new&personID={0}", lblIDPerson.Text.Trim());
 
RadWindow newWindow = new RadWindow();
newWindow.NavigateUrl = url;
newWindow.VisibleOnPageLoad = true;
newWindow.Height = 300;
newWindow.Width = 550;
RadWindowEditors.Windows.Add(newWindow);


Thanks


Jhon Williams
Top achievements
Rank 1
 answered on 31 May 2013
1 answer
582 views
Hello, 
How to extract values from a GridEditFormItem from server side.
Here is my code.

ASP Markup :
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" CellSpacing="0"
    Skin="Transparent" GridLines="None" PageSize="10" AllowCustomPaging="True" AutoGenerateColumns="False"
    AllowSorting="True" OnItemDataBound="RadGrid1_ItemDataBound1" OnRowDrop="RadGrid1_OnRowDrop"
    AllowAutomaticUpdates="true" OnUpdateCommand="RadGrid1_UpdateCommand">
    <PagerStyle Mode="NumericPages" />
    <ClientSettings AllowRowsDragDrop="True">
        <Selecting AllowRowSelect="true" />
        <ClientEvents OnRowDropping="rowDropping" OnRowDblClick="RowDblClick" OnCommand="GridCommand" />
        <Resizing AllowColumnResize="true" />
    </ClientSettings>
    <MasterTableView AllowCustomPaging="False" AutoGenerateColumns="false" Caption="<%$Resources:BrandixResources, PWI_UnplannedItemsGrid_Title%>"
        Visible="True" DataKeyNames="ID, Effort" AllowNaturalSort="false" ClientDataKeyNames="Subject, Description, Effort">
        <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
        <SortExpressions>
            <telerik:GridSortExpression FieldName="DueDateTime" SortOrder="Ascending" />
        </SortExpressions>
        <Columns>
            <telerik:GridBoundColumn UniqueName="ID" Visible="false" DataField="ID" ReadOnly="True">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn HeaderText="<%$Resources: Resources, Subject%>"
                DataField="Subject" UniqueName="Subject" ReadOnly="True">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn HeaderText="<%$Resources: Resources,  DueDate%>"
                DataField="DueDateTime" DataFormatString="{0:dd/MM/yyyy} {0:hh}:{0:mm} {0:tt}"
                ReadOnly="True">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn HeaderText="<%$Resources: Resources, Effort%>"
                DataField="Effort">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn HeaderText="<%$Resources: Resources,  UnplannedHours%>"
                DataField="UnplannedHours" ReadOnly="True">
            </telerik:GridBoundColumn>
            <telerik:GridTemplateColumn HeaderText="<%$Resources: Resources,  DraftPlan%>"
                UniqueName="DraftPlan" SortExpression="Status" ReadOnly="True">
                <ItemTemplate>
                    <asp:Label ID="lblGridStatus" runat="server" />
                </ItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
        <EditFormSettings>
            <EditColumn UniqueName="EditCommandColumn1">
            </EditColumn>
        </EditFormSettings>
    </MasterTableView>
</telerik:RadGrid>

Javascript : 

var editedRow;
 
        function RowDblClick(sender, eventArgs) {
            editedRow = eventArgs.get_itemIndexHierarchical();
            $find("<%= RadGrid1.ClientID %>").get_masterTableView().editItem(editedRow);
        }
 
        function GridCommand(sender, args) {
            if (args.get_commandName() != "Edit") {
                editedRow = null;
            }
        }


C# code : 
Attempt 1 :
protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
{
    GridEditableItem item = e.Item as GridEditableItem;
    Dictionary<string, string> values = new Dictionary<string, string>();
    item.ExtractValues(values);
    int id = Convert.ToInt32(item.GetDataKeyValue("ID"));
}

Attempt 2 : 
protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
{
    GridEditableItem item = e.Item as GridEditableItem;
    Dictionary<string, string> values = new Dictionary<string, string>();
    e.Item.OwnerTableView.ExtractValuesFromItem(values, item);
}

When I double click a row, the edit form pops below the row. But when I change the value and click update. It is not getting the new value. Instead its getting the old value. Please tell me how to get the new value.

Img1 : The new value I entered,
Img2 : Value I get from the code.

Really need some help on this.
Elliott
Top achievements
Rank 2
 answered on 30 May 2013
7 answers
525 views
Hi All

I have a radgrid and a button

While clicking the button the datas in the radgrid in exported to the pdf.

But the font size in pdf is 12pt.

I want it to be 8pt.

Is there any possible way.

Thank you

-Anto
L
Top achievements
Rank 1
 answered on 30 May 2013
4 answers
183 views
I generate the columns for my RadGrid in code behind.  I do this by creating a DataTable from a stored procedure and then binding the DataTable to the RadGrid.  I now want to display a graphic in certain columns based in the information in that cell.  I normally do it in the .aspx code like this:
<telerik:GridTemplateColumn DataField="State" DataType="System.Boolean" FilterControlAltText="Filter Public column" HeaderText="State" SortExpression="State" UniqueName="State">
<ItemTemplate>
<asp:Image ID="Image1" ImageUrl="~/images/true.png" Visible='<%# (bool)Eval("State") == true %>' runat="server" />
<asp:Image ID="Image2" ImageUrl="~/images/false.png" Visible='<%# (bool)Eval("State") == false %>' runat="server" />
</ItemTemplate>
</telerikf:GridTemplateColumn>
I can't seem to figure out how to do this in code behind.  I can add an image to the column, but it is the same image for all cells in the column.  I don't know where to add code (in the column definition) that changes the image based on the value of the cell.  Here is how I create the column and add an image which is the same for all cells.         
string templateColumnName = dc.ColumnName;
GridTemplateColumn templateColumn = new GridTemplateColumn();
templateColumn.ItemTemplate = new MyItemTemplate(templateColumnName);
templateColumn.HeaderText = templateColumnName;
templateColumn.DataField = dc.ColumnName;
this.RadGrid1.MasterTableView.Columns.Add(templateColumn);
 
private class MyItemTemplate : ITemplate 
        protected Image myimage;
        private string colname;
        public MyItemTemplate(string cName) 
        
            colname = cName; 
        
        public void InstantiateIn(System.Web.UI.Control container) 
        {
            myimage = new Image();
            myimage.ImageUrl = ""// Setting an image here works, but is the same for all cells
            myimage.ID = "templateColumnImage";
            container.Controls.Add(myimage);            
       
}

I have thought of adding the rows to the RadGrid one at a time, but I would rather define the column and then just bind the RadGrid to the DataTable.  I also want to select between more than two images, so the "Visable = (bool)Eval" in the first example is not sufficient, but I figure I can change a given solution to work how I want it. 
Scott
Top achievements
Rank 1
 answered on 30 May 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?