Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
260 views
I was having issues with prometheus running when using a Master page... I have found a thread that states to remove the runat = server from the head tag and insert 
<script>var controlClientObject = <%= RadControl1.ClientID %></script>
below is how I have added it in my master page.
 

<

body style="margin: 0px;" runat=server>

<form id="frmMaster" >

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">

<Scripts>

<asp:ScriptReference Path="~/Scripts/setFooter.js" />

</Scripts>

</asp:ScriptManager>

<

script>var controlClientObject = <%= RadControl1.ClientID %></script>

<div id="Header">

Now I get the following error... Can someone please help me as to what I am missing?

Compiler Error Message: CS0103: The name 'RadControl1' does not exist in the current context

I have made sure everything is in the web config and I do have the dll in the bin folder... I am able to to run everything fine as long as I do not use a master page?

Thanks for the help
Gina

Peter
Telerik team
 answered on 11 Mar 2011
1 answer
70 views
Hi Sir / Madam,

I am using Hierarchical grid to display Master & Details information. I want page size as 10 and 5 respectively in MasterTableView and DetailTables. For uniqueness in entire application i would like to go with asp.net's skin file. I have written below listed code in Skin1.skin file

<telerik:RadGrid runat="server"  >
<MasterTableView  PageSize="10">
</MasterTableView>
</telerik:RadGrid>
<telerik:GridTableView  Width="100%" PageSize="5" runat="server">
</telerik:GridTableView>

But end result was not met my expectation. Both Master and Child tables displays 5 records per page.

If I use same settings in .aspx page instead of skin file, results are displayed as expected.

Could any one please help me in this regard. Thanks in advance.

Thanks,
Sumanth

 
Tsvetoslav
Telerik team
 answered on 11 Mar 2011
1 answer
124 views
I have a column named 'Unread' in my Rad grid. Please see the following aspx code.

<Telerik:RadGrid ID="MessageBoardRadGrid"  Width="100%" AllowSorting="True" PageSize="15" AllowPaging="True" 
              AllowMultiRowSelection="True" runat="server" Gridlines=Both  HeaderStyle-Font-Bold=true 
              AutoGenerateColumns="False"  >
               <PagerStyle Mode="NextPrevAndNumeric" />                  
               <MasterTableView DataKeyNames="Name" AutoGenerateColumns="false">
                   <Columns>                           
                       <Telerik:GridTemplateColumn  DataField="Unread" HeaderText="Unread" HeaderStyle-CssClass="gridheader">                    
                           <ItemTemplate>
                               <%# Formatter.StatusIcon( (Forum) Container.DataItem ) %>
                           </ItemTemplate>
                       </Telerik:GridTemplateColumn >

I am binding an image if there is an most resent update on the column.
Please find the code for the StatusIcon() method below.
if (forum.LastUserActivity < forum.MostRecentPostDate) 
        {
            icon = "forum_status_new_ln.gif";
            alt = ResourceManager.GetString("IconAlt_NewPosts");
        }

I want to make it a default sorted column to show the unread items first.
Kindly help me accomplishing this.
Princy
Top achievements
Rank 2
 answered on 11 Mar 2011
1 answer
108 views
Can you add a row of data programatically and aggregate it within the radgrid.  If so, how?

Example:

I have a grid with 2 columns.  One of these columns is a template that runs a function and delivers an output.  Within that function I need to manually add data that is not present in the sqldatasource to the grid and use it when performing aggregate functions. 

ColumnA - ColumnB
1 - MyFunction(1) - adds new row (1, B)and returns A to column B.  
2 - MyFunction(2) - May return just A

Grid should look like
1 - A
1 - B
2 - A
Count 3

Even though SQLDataSource only returns
1 - AB
2 - A

Of course the function is more complex than the example above and I only need details on adding the row of data to the grid so that it can be aggregated.  Thanks

Tsvetoslav
Telerik team
 answered on 11 Mar 2011
2 answers
61 views
Hi there,


I used to have a child window which referenced a js function (let's say MyFunc) on parent by using window.opener.MyFunc().
I changed to radopen and window.opener.MyFunc() does not work now.
I first thought it was due that child is not exactly a different window so I just used MyFunc() but it still does not work.
So, how can I reference a js function on opener in child window which was opened with radopen?

Thank you so much,


Javier Andrés Cáceres Alvis
Shinu
Top achievements
Rank 2
 answered on 11 Mar 2011
1 answer
120 views
hi,

I am using   the following paging style <PagerStyle Mode="NextPrevNumericAndAdvanced"></PagerStyle> on radgrid.
If I enter the maximum number in the number of record fields and click "Change" though I see all the records, the paging panel disappears.

Looks like a bug in Radgrid. Any help?

Kind Regards
Princy
Top achievements
Rank 2
 answered on 11 Mar 2011
1 answer
74 views
Dear all
We have recently encountered a very serious issue with the previous vesion of the radupload for ASP.NET and statusmanger in particular. I can consistently simulate the error, I was just wondering if anyone has seen this in the latest version as well.

When two web users are uploading at the same time, the user that starts an upload after another user has one in process will for a couple of seconds see the file and filename of the other user that is being uploaded, after which it changes to display the correct file that he is busy uploading. After about 50% completion, both users will get an error message that their upload has failed.

I can consistently simulate this, with more users it becomes even more obvious as you first see for a couple of seconds all the files being uploaded by the other users before it will display the status of your file, after which all uploads will fail.

Is there anyone out there that can confirm this behaviour, or confirm that this has been fixed in the new releases of this component?
Tonie Venter
Top achievements
Rank 1
 answered on 11 Mar 2011
0 answers
64 views
Hi,

I have a combox that only should close when the arrow is selected. To do this, I am using the OnClientDropDownClosing event. The code below does eactly what I want it to do, only close when arrow is selected. When the dropdown arrow is selected, the OnClientDropDownClosing is called, the dropdown closes, then the OnClientDropDownClosed is called and everything works fine.
  
CONTROL:

telerik:RadComboBox ID="RadComboBoxStringInLookupValue" Runat="server" Width="325px" AllowCustomText="True" 
    EmptyMessage="<%$ Resources:CommonUserMsg, EnterValueMsgResource %>" EnableTextSelection="False" 
    DropDownWidth="325px" HighlightTemplatedItems="True" Visible="true" OnClientDropDownClosing="OnClientDropDownClosing" 
    OnClientDropDownClosed="populateComboBoxEmptyMessage" CausesValidation="False" >
    <ItemTemplate>
        <ul>
         <li class="col1">
           <telerik:RadListBox ID="RadListBoxSource" runat="server" Height="125px" DataSourceID="ObjectDataSourceLookUpValues" 
                DataTextField="Descr" DataValueField="Code" AllowTransfer="true" TransferToID="RadListBoxDestination" 
                AllowTransferOnDoubleClick="True" SelectionMode="Multiple" OnClientSelectedIndexChanged="SetCanvasChanged" 
                ondatabound="OnDataBound" onitemdatabound="OnItemsDataBound" >
               <ButtonSettings ReorderButtons="Common"></ButtonSettings>
           </telerik:RadListBox
         </li>    
         <li class="col2">
            <telerik:RadListBox ID="RadListBoxDestination" runat="server" Height="125px"  SelectionMode="Multiple"
               <ButtonSettings ReorderButtons="Common"></ButtonSettings>
            </telerik:RadListBox
         </li>                                 
        </ul>
      </ItemTemplate
      <Items>
          <telerik:RadComboBoxItem Text="" />
      </Items>           
</telerik:RadComboBox>

OnClientDropDownClosing Function

 

 

 

function OnClientDropDownClosing(sender, args) {
     args.set_cancel(false);
     var target = args.get_domEvent().target;
  
     //cancel drop-down closing only when clicked inside and not on the arrow
     if (target && target != sender.get_imageDomElement() && (jQuery.contains(sender.get_element(), target) ||   
           jQuery.contains(sender.get_dropDownElement(), target)))
     {
              args.set_cancel(true);
     }
}
This all worked; but then we added Ajax to the mix and it has stopped working. Now here what's happening.

OnClientDropDownClosing is called everytime a click is made in the drop down and remains open like I want it to; then once the dropdown arrow is clicked, it calls OnClientDropDownClosing, closes the dropdown, then opens it again..Never Calling the OnClientDropDownClosed event, which I am guessing is because the dropdown opens again.

Could it not be working because of the AJAX?

Thanks,
Gary

gary
Top achievements
Rank 1
 asked on 10 Mar 2011
2 answers
97 views
I'm sure many Telerik users must have encountered situations where the code-behind begins to bloat to epic proportions if you have a few grids and lots of events that need to be taken care of.

For example, I have a TabStrip with 14 tabs and Telerik controls like grids and so on in every one. You can imagine how the code behind is scaling. The UI is fantastic to the end user but behind the scenes, it's all becoming dark and mysterious.

Has anyone developed a best practice in handling the ever increasing lines of code in code-behind? I'm aware of splitting the file into seperate partial files but I don't like having to edit the project file to nest those files.

I've already made as much use of the declarative syntax as I can.

Interesting topic. Regions can only take you so far when there's 1,000+ lines in your code-behind handling all those command, needdatasource, databind events, etc. ;0

Richard
Richard Weeks
Top achievements
Rank 2
 answered on 10 Mar 2011
1 answer
135 views
Hello, I am using declaritive client side data binding. I need to rebind the grid when a checkbox (RadButton) is checked. I have verified (using web development helper) that valid JSON is returning from my PageMethods call, but after the tableView.dataBind(); the RadGridPractices_DataBinding function is not invoked and the grid continues to display the old rows and adds the 'No records to display' message at the bottom of the grid. Paging, sorting, filtering all work and i am calling the same webmethod for my rebind.  I wonder if it is something to do with the non standard Grid DataBinding parameters? I have looked at various examples and the Client-side binding topic. I am at a loss.

Here is the JSON:
{"d":{"Practices":[{"PracticeID":2,"PTypeID":1,"PracticeDesc":"Storage Tank 1","PracticeType":"Aboveground storage tank","AspectID":4,"luAspectID":3,"Aspect":"Electricity use","ImpactID":0,"luImpactID":0,"Impact":"","IsActive":true,"Score":"11.2","ScoreMax":"55","ScoreAvg":"24.62"},{"PracticeID":2,"PTypeID":1,"PracticeDesc":"Storage Tank 1","PracticeType":"Aboveground storage tank","AspectID":5,"luAspectID":4,"Aspect":"Fire/explosion","ImpactID":0,"luImpactID":0,"Impact":"","IsActive":true,"Score":"55","ScoreMax":"55","ScoreAvg":"24.62"}],"PracticeCount":11}}

Here is some code:
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
         
        function RadButtonIncludeAspects_OnClientCheckedChanged(sender, args) {
           var aspectsButton = $find("<%= RadButtonIncludeAspects.ClientID %>");
           var impactsButton = $find("<%= RadButtonIncludeImpacts.ClientID %>");
  
           if (!aspectsButton.get_checked()) {
               // need aspects to select impacts 
               impactsButton.set_checked(false);
           }
  
           var includeAspects = aspectsButton.get_checked().toString();
           var includeImpacts = impactsButton.get_checked().toString();
  
           var tableView = $find("<%= RadGridPractices.ClientID %>").get_masterTableView();
           var currentPageIndex = tableView.get_currentPageIndex();
           var pageSize = tableView.get_pageSize();
           var sortExpressions = tableView.get_sortExpressions();
           var filterExpressions = tableView.get_filterExpressions();
  
           PageMethods.GetPracticesAndCount(currentPageIndex, pageSize,
               "", "", installationID,
               installationModifier, environmentalWeight, regulatoryWeight,
              publicPerceptionWeight, healthAndSafetyWeight, includeAspects, includeImpacts, bindGrid);
       }
  
       function bindGrid(result) {
           //debugger;
           var tableView = $find("<%= RadGridPractices.ClientID %>").get_masterTableView();
           tableView.set_dataSource(result);
           tableView.dataBind();
  
           //var grid = $find("<%= RadGridPractices.ClientID %>");
           //grid.repaint();
       }
  
       function RadGridPractices_OnCommand(sender, args) {
           // Handle the RadGrid's Command event here  
       }
  
       function RadGridPractices_OnRowDataBound(sender, args) {
       //debugger; 
          if (args.get_dataItem()['Score'] >= 18) {
              args.get_item().get_cell('column').style.color='#FF3300';
              args.get_item().get_cell('PracticeType').style.color='#FF3300';
              args.get_item().get_cell('PracticeDesc').style.color='#FF3300';
              args.get_item().get_cell('Aspect').style.color='#FF3300';
              args.get_item().get_cell('Impact').style.color='#FF3300';
              args.get_item().get_cell('Score').style.color='#FF3300';
              args.get_item().get_cell('ScoreAvg').style.color='#FF3300';
              args.get_item().get_cell('ScoreMax').style.color='#FF3300';
          }
          else if (args.get_dataItem()['Score'] >= 11) {
              args.get_item().get_cell('column').style.color='#FF9900';
              args.get_item().get_cell('PracticeType').style.color='#FF9900';
              args.get_item().get_cell('PracticeDesc').style.color='#FF9900';
              args.get_item().get_cell('Aspect').style.color='#FF9900';
              args.get_item().get_cell('Impact').style.color='#FF9900';
              args.get_item().get_cell('Score').style.color='#FF9900';
              args.get_item().get_cell('ScoreAvg').style.color='#FF9900';
              args.get_item().get_cell('ScoreMax').style.color='#FF9900';
          }
          else if (args.get_dataItem()['Score'] >= 7) {
              args.get_item().get_cell('column').style.color='#00CC00';
              args.get_item().get_cell('PracticeType').style.color='#00CC00';
              args.get_item().get_cell('PracticeDesc').style.color='#00CC00';
              args.get_item().get_cell('Aspect').style.color='#00CC00';
              args.get_item().get_cell('Impact').style.color='#00CC00';
              args.get_item().get_cell('Score').style.color='#00CC00';
              args.get_item().get_cell('ScoreAvg').style.color='#00CC00';
              args.get_item().get_cell('ScoreMax').style.color='#00CC00';
          }
          else {
              args.get_item().get_cell('column').style.color='#000000';
              args.get_item().get_cell('PracticeType').style.color='#000000';
              args.get_item().get_cell('PracticeDesc').style.color='#000000';
              args.get_item().get_cell('Aspect').style.color='#000000';
              args.get_item().get_cell('Impact').style.color='#000000';
              args.get_item().get_cell('Score').style.color='#000000';
              args.get_item().get_cell('ScoreAvg').style.color='#000000';
              args.get_item().get_cell('ScoreMax').style.color='#000000';
          }
       }
  
       function RadGridPractices_DataBinding(sender, args) {
          alert('databinding');
  
          var aspectsButton = $find("<%= RadButtonIncludeAspects.ClientID %>");
          var includeAspects = aspectsButton.get_checked().toString();
          var impactsButton = $find("<%= RadButtonIncludeImpacts.ClientID %>");
          var includeImpacts = impactsButton.get_checked().toString();
            
          var methodArguments = args.get_methodArguments();
          var myMethodArguments = methodArguments;
            
          myMethodArguments.installationID = installationID;
          myMethodArguments.installationModifier = installationModifier;
          myMethodArguments.environmentalWeight = environmentalWeight;
          myMethodArguments.regulatoryWeight = regulatoryWeight;
          myMethodArguments.publicPerceptionWeight = publicPerceptionWeight;
          myMethodArguments.healthAndSafetyWeight = healthAndSafetyWeight;
          myMethodArguments.includeAspects = includeAspects;
          myMethodArguments.includeImpacts = includeImpacts;
            
          args.set_methodArguments(myMethodArguments); 
       };
         
       function RadGridPractices_OnRowSelected(sender, args) {
       //   alert('TODO: Highlight associated Commands and Locations');
       };
         
       function RadGridPractices_OnRowDeselected(sender, args) {
       //   alert('TODO: Highlight associated Commands and Locations');
       };
         
       </script>
   </telerik:RadCodeBlock>
  
<table style="width: 100%;">
     <tr>
        <td>
            <telerik:RadButton ID="RadButtonIncludeAspects" runat="server" 
                ButtonType="ToggleButton" Text="Include Aspects" ToggleType="CheckBox" 
                Checked="True" 
                onclientcheckedchanged="RadButtonIncludeAspects_OnClientCheckedChanged" 
                AutoPostBack="False">
            </telerik:RadButton> 
            <telerik:RadButton ID="RadButtonIncludeImpacts" runat="server" 
                ButtonType="ToggleButton" Text="Include Impacts" ToggleType="CheckBox" 
                Checked="True" 
                OnClientCheckedChanged="RadButtonIncludeImpacts_OnClientCheckedChanged"
                AutoPostBack="False">
            </telerik:RadButton>
        </td>
    </tr>     
    <tr>
        <td>
<telerik:RadGrid ID="RadGridPractices" runat="server" AllowPaging="True" 
            GridLines="None" PageSize="2" AllowFilteringByColumn="True" 
    AllowSorting="True" AllowMultiRowSelection="True">
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>
  
<MasterTableView AutoGenerateColumns="False">
<CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
  
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
  
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
  
    <Columns>
        <telerik:GridClientSelectColumn FilterControlAltText="Filter column column" 
            UniqueName="column">
        </telerik:GridClientSelectColumn>
<%--        <telerik:GridBoundColumn DataField="PracticeID" DataType="System.Int32" 
            FilterControlAltText="Filter PracticeID column" HeaderText="ID" 
            ReadOnly="True" SortExpression="PracticeID" UniqueName="PracticeID">
        </telerik:GridBoundColumn>--%>
        <telerik:GridBoundColumn DataField="PracticeType" 
            FilterControlAltText="Filter PracticeType column" HeaderText="Practice Type" 
            ReadOnly="True" SortExpression="PracticeType" UniqueName="PracticeType">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="PracticeDesc" 
            FilterControlAltText="Filter PracticeDesc column" HeaderText="Practice" 
            ReadOnly="True" SortExpression="PracticeDesc" UniqueName="PracticeDesc">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Aspect" 
            FilterControlAltText="Filter Aspect column" HeaderText="Aspect" 
            ReadOnly="True" SortExpression="Aspect" UniqueName="Aspect">
        </telerik:GridBoundColumn>        
        <telerik:GridBoundColumn DataField="Impact" 
            FilterControlAltText="Filter Impact column" HeaderText="Impact" 
            ReadOnly="True" SortExpression="Impact" UniqueName="Impact">
        </telerik:GridBoundColumn>        
        <telerik:GridBoundColumn DataField="Score" 
            FilterControlAltText="Filter Score column" HeaderText="Score" 
            ReadOnly="True" SortExpression="Score" UniqueName="Score">
        </telerik:GridBoundColumn>        
        <telerik:GridBoundColumn DataField="ScoreAvg" 
            FilterControlAltText="Filter ScoreAvg column" HeaderText="Avg" 
            ReadOnly="True" SortExpression="ScoreAvg" UniqueName="ScoreAvg">
        </telerik:GridBoundColumn>        
        <telerik:GridBoundColumn DataField="ScoreMax" 
            FilterControlAltText="Filter ScoreMax column" HeaderText="Max" 
            ReadOnly="True" SortExpression="ScoreMax" UniqueName="ScoreMax">
        </telerik:GridBoundColumn>        
    </Columns>
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
</EditFormSettings>
</MasterTableView>
  
            <ClientSettings>
                <DataBinding Location="PAI.aspx" 
                    SelectMethod="GetPracticesAndCount" FilterParameterType="Linq" 
                    CountPropertyName="PracticeCount" DataPropertyName="Practices" 
                    FilterParameterName="filterExpressions" MaximumRowsParameterName="rowCount" 
                    SortParameterName="sortExpressions" SortParameterType="Linq" 
                    StartRowIndexParameterName="startIndex">
                </DataBinding>
                <Selecting AllowRowSelect="True" EnableDragToSelectRows="true" />
                <ClientEvents OnDataBinding="RadGridPractices_DataBinding" 
                    OnRowSelected="RadGridPractices_OnRowSelected" 
                    OnRowDeselected="RadGridPractices_OnRowDeselected" 
                    OnRowDataBound="RadGridPractices_OnRowDataBound"
                    OnCommand="RadGridPractices_OnCommand" />
            </ClientSettings>
  
<FilterMenu EnableImageSprites="False"></FilterMenu>
        </telerik:RadGrid>
        </td>
    </tr>
</table>
Marcel
Top achievements
Rank 1
 answered on 10 Mar 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?