Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
243 views
Hello
How can i disable or hide one RadToolBarButton in CommandItemTemplat of grid
 when select row of grid??
Princy
Top achievements
Rank 2
 answered on 13 Jan 2009
5 answers
258 views
hi

How do i show grid value based on select value from a listbox? I am using a stored procedures:

Create PROCEDURE [dbo].[spByInfoID]
@ID varchar(500)
AS
BEGIN
SET NOCOUNT ON;
SELECT * from tblInfo
WHERE  ',' + @ID + ',' LIKE '%,' + CAST(infoID AS varchar(10)) + ',%'

I configured radgrid as SQLDatasource using this stored procedures and parameter source is Control and the Control id is a listbox. No default value.

I may have done it the wrong way. But do enlighten me. Thanks
Yavor
Telerik team
 answered on 13 Jan 2009
2 answers
100 views
I'm using a RadGrid with row selecting enabled where one of the columns of the grid is a hyperlink column.
When the user clicks on a link, another window pops up with some information.

The row selection check boxes are there to allow the user to delete a row, but when they click on a link, sometimes that row will be selected.

I would like to allow the user to select a row by only clicking on the check box. The row doesn't even have to become highlighted, as long as the check box shows as checked and the row gets added to the SelectedRows collection on server side.

Please advise.

Regards,

Rod
Rod
Top achievements
Rank 1
 answered on 13 Jan 2009
7 answers
334 views
Hello guys,

I tried to have a look on existing threads and found nothing about the issue I encounter so I apologize in advance if you already have treaten this case.

I have an issue with an automatic update, it seems that data value stored in bound columns marked as readonly are not sent to the update command ... because when the update is performed the read-only field is blanked :(

I don't think this is the normal behavior, right ?!

I did my tests with a Northwind Sql DataSource, using IE7.

Do not hesitate if you need much information.

Hope hear from you soon.
Darren
Top achievements
Rank 1
 answered on 13 Jan 2009
2 answers
121 views
Hi ,

Could you please provide some sample code for resize radwindow in user control.

Also i need to resize in codebehind.
like after button click in radwidow ,resize the radwindow.

Thanks.
Eva 
Eva
Top achievements
Rank 1
 answered on 13 Jan 2009
0 answers
454 views
I tried to get your RadTreeView to work in a RadComboBox within the RadAjaxManager.
(C# VS 2008, .Net 3.5 SP1, RAD 2008 Q3)

But the following js client api calls for set_text and set_checked weren't working after the first ajax postback, that is,... until after user opened the combobox!

After hours of debugging I found a hack for the combo set_text ...
        comboBox.get_items()._array[0]._text = aString;
        comboBox.set_text(aString);

Then after more hours, the combox set_checked hack was (implemented in Attempt #2):
        OnClientDropDownOpened="radComboBox_DDOpen"

I had to scrap your treeview and implement a custom control array of HTML checkboxes because it wasn't working inside the combo, and also wasn't otherwise controllable via your client-api.

(Had the code I wrote from the OnClientDropDownOpened event not worked I would have been forced to scrap both of your telerik controls as a solution.)

Then I noticed after the first ajax postback, that the combo would close after the first mouse click on the treeview or checkbox control array, which wasn't what the user needed (they needed multi-selection before close)... 

At first I thought that the OnClientDropDownClosing event might have an arg that I could identify the source of the event to cancel, but that solution wasn't obvious,  so I ended up using...
     window.event.cancelBubble = true; (JS Hack implemented in Attempt #2):

My solution did work, however, finding the workaround for these bugs delayed our production release (not to mention the uglyness and headache of the solution).

All 11 senior devs on our team came to the same consensus, 
Telerik needs to perform more QA and provide better documentation.



Code Attempt #1:

    function ToggleTreeViewCheckList(currentNode)
    {
        var comboBox = $find('<%=radComboBox.ClientID%>');
        var treeView = $find('<%=getTreeViewID() %>');
        var aString="";

        if (treeView.get_nodes())
        {
            //if current node checked-change is index 0
            if (currentNode.get_index() == 0)
            {
                //Don't move this if statement, must be standalone
                if (currentNode.get_checked())
                {
                    //put -All- in temp string
                    aString = treeView.get_nodes().getNode(0).get_text();
                }
               
               //loop through all nodes, excluding index 0
               for (var i=1; i<treeView.get_nodes().get_count();i++)
               {        
                   var node = treeView.get_nodes().getNode(i);
                  
                   if (AllowCheckChange)
                   {
                        //ensure all nodes are toggled accordingly
                        node.set_checked(currentNode.get_checked());
                   }
               }
            }
            //if there are nodes
            else if (treeView.get_nodes().get_count() > 0)
            {
               var CheckedNodeCount = 0;
               var tempstring = '';
               //loop, excluding index 0
               for (var i=1; i<treeView.get_nodes().get_count();i++)
               {        
                   var node = treeView.get_nodes().getNode(i);
                   if (node.get_checked())
                   {
                        //if node is checked add to temp string
                        CheckedNodeCount++;
                        tempstring += ',' + node.get_text();
                   }
               }
              
               //if all the nodes are checked (excluding one for index 0)
               if (CheckedNodeCount == treeView.get_nodes().get_count() - 1)
               {
                    if (AllowCheckChange)
                    {
                        //set text to '- All -' and check index 0
                        treeView.get_nodes().getNode(0).set_checked(true);
                    }
                    aString = treeView.get_nodes().getNode(0).get_text();
               }
               else
               {
                    if (AllowCheckChange)
                    {
                        //ensure index 0 is not checked
                        treeView.get_nodes().getNode(0).set_checked(false);
                    }
                    //remove extra comma from temp string
                    aString = tempstring.substring(1, tempstring.length);
               }
            }
        }
  
        comboBox.get_items()._array[0]._text = aString;
        comboBox.set_text(aString);
    }













Code Attempt #2:


 

<%

@ Control Language="C#" AutoEventWireup="true" CodeBehind="ComboTreeView.ascx.cs"

 

 

 

 

 

Inherits="WebInterface.WebControls.ComboTreeView" %>

 

<%

@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

 

 

 

 

<

script language="javascript" type="text/javascript">

 

 

 

 

 

//Flag for executing checking function

 

 

var RetailerCheckTheItems = false;

 

 

 

//Flag for locking checked items

 

 

var RetailerSearchLockItems = false;

 

 

 

//Instance of the Retailer CheckBox (set on NameLookup page)

 

 

//Needed to maintain viewstate on postback with ajax enabled

 

 

var RetailerCheckBox;

 

 

 

function SelectRetailerTreeViewItems(IsRetailerSearch)

 

{

RetailerCheckTheItems = IsRetailerSearch;

RetailerSearchLockItems = IsRetailerSearch;

CheckRetailerListItem();

}

 

 

function CheckRetailerListItem()

 

{

 

var comboBox = $find('<%=radComboBox.ClientID%>');

 

 

var itemsToCheck=new Array();

 

itemsToCheck[0] =

"Section1";

 

itemsToCheck[1] =

"Section2";

 

itemsToCheck[2] =

"Section3";

 

itemsToCheck[3] =

"Section4";

 

itemsToCheck[4] =

"Section5";

 

 

 

if (RetailerCheckTheItems)

 

{

 

var aString='';

 

 

var tempstring='';

 

 

 

for (var x=0; x<itemsToCheck.length; x++)

 

{

tempstring +=

',' + itemsToCheck[x];

 

}

 

 

//remove extra comma from temp string

 

 

 

 

aString = tempstring.substring(1, tempstring.length);

 

comboBox.get_items()._array[0]._text = aString;

comboBox.set_text(aString);

 

 

//loop through all nodes

 

 

 

 

 

var CheckControls = document.getElementsByName('CheckListItems');

 

 

for (i = 0; i < CheckControls.length; i++)

 

{

document.getElementById(

'CheckListItems' + i).checked = false;

 

 

for (var y=0; y<itemsToCheck.length; y++)

 

{

 

//if the checkbox value matches the list item, check it

 

 

 

 

 

if (document.getElementById('CheckListItems' + i).value == itemsToCheck[y])

 

{

document.getElementById(

'CheckListItems' + i).checked = true;

 

}

}

}

}

}

 

 

function radComboBox_DDOpen()

 

{

 

if (RetailerCheckBox)

 

{

 

 

//Lock Checkbox List if Retailer Search is Checked

 

 

 

 

 

//even after a postback without ajax.

 

 

 

 

RetailerSearchLockItems = RetailerCheckBox.checked;

}

CheckRetailerListItem();

 

if (RetailerCheckTheItems)

 

{

RetailerCheckTheItems =

false;

 

}

}

 

 

function CheckList_CheckChange(Index)

 

{

 

if (!RetailerSearchLockItems)

 

{

 

var comboBox = $find('<%=radComboBox.ClientID%>');

 

 

var aString = '';

 

 

 

if (Index == 0)

 

{

 

if (document.getElementById('CheckListItems0').checked)

 

{

aString = document.getElementById(

'CheckListItems0').value;

 

}

 

var CheckControls = document.getElementsByName('CheckListItems');

 

 

for (i = 0; i < CheckControls.length; i++)

 

{

CheckControls[i].checked = document.getElementById(

'CheckListItems' + Index).checked;

 

}

}

 

else if (Index > 0)

 

{

 

var CheckedNodeCount = 0;

 

 

var tempstring = '';

 

 

//loop, excluding index 0

 

 

 

 

 

var CheckControls = document.getElementsByName('CheckListItems');

 

 

for (i = 1; i < CheckControls.length; i++)

 

{

 

if (document.getElementById('CheckListItems' + i).checked)

 

{

 

//if node is checked add to temp string

 

 

 

 

CheckedNodeCount++;

tempstring +=

',' + CheckControls[i].value;

 

}

}

 

//if all the nodes are checked (excluding one for index 0)

 

 

 

 

 

if (CheckedNodeCount == CheckControls.length - 1)

 

{

 

//set text to '- All -' and check index 0

 

 

 

 

document.getElementById(

'CheckListItems0').checked = true;

 

aString =

'- ALL -';

 

}

 

else

 

 

 

 

{

 

//ensure index 0 is not checked

 

 

 

 

document.getElementById(

'CheckListItems0').checked = false;

 

 

//remove extra comma from temp string

 

 

 

 

aString = tempstring.substring(1, tempstring.length);

}

}

comboBox.get_items()._array[0]._text = aString;

comboBox.set_text(aString);

}

window.event.cancelBubble =

true;

 

}

 

function <%=this.ClientID %>_radComboBox_onClick(){

 

}

 

function <%=this.ClientID %>_radComboBox_OnClientFocus(sender){

 

}

 

function <%=this.ClientID %>_radComboBox_OnBlur(sender){

 

}

 

function StopPropagation(e) {

 

 

if (!e) {

 

e = window.event;

}

e.cancelBubble =

true;

 

}

 

 

function <%=this.ClientID %>_radComboBox_KeyPress(p1, p2){

 

 

if (window.event.keyCode==13){

 

}

 

}

 

 

</script>

 

 

 

 

<

telerik:RadComboBox ID="radComboBox" style="margin: 0px 0px 1px 0px;"

 

 

OnClientDropDownOpened="radComboBox_DDOpen" runat="server" Height="190px" Width="177" ShowToggleImage="True"

 

 

 

 

 

ShowMoreResultsBox="false" EnableEmbeddedSkins="false" Skin="CustomSkin" DropDownWidth="175">

 

 

 

 

 

<ItemTemplate>

 

 

 

 

 

<div id="div1" runat="server" style="margin-left: 0px; padding: 3px 0px 0px 0px;">

 

 

 

 

 

<ul style="width: 175px; list-style: none; margin: 0; padding: 0;">

 

 

 

 

 

<asp:Repeater ID="rptCheckList" runat="server">

 

 

 

 

 

<ItemTemplate>

 

 

 

 

 

<li>

 

 

<asp:Literal ID="litCheckBox" runat="server" />

 

 

 

 

 

<a id="CheckboxClicker" runat="server"><asp:Label ID="Label1" runat="server" Text="Label" /></a>

 

 

 

 

 

</li>

 

 

</ItemTemplate>

 

 

</asp:Repeater>

 

 

</ul>

 

 

 

 

 

</div>

 

 

 

 

 

</ItemTemplate>

 

 

 

 

 

<Items>

 

 

 

 

 

<telerik:RadComboBoxItem Text="" />

 

 

 

 

 

</Items>

 

</

telerik:RadComboBox>

 

<

script type="text/javascript">

 

 

 

 

 

var div1 = document.getElementById("<%=radComboBox.ClientID %>_i0_div1");

 

div1.onclick = StopPropagation;

 

 

 

</

script>

 

 

 



c# codebehind as follows...

 

 

 

public string getCSVofCheckedText() {

 

 

string returnvalue = string.Empty;

 

 

if (IsPostBack)

 

{

returnvalue =

this.Request.Form["ctl00$MainContent$Search2$cboExternalTypes$radComboBox_Input"];

 

}

 

return returnvalue;

 

}

 


 

 

protected void rptCheckList_ItemDataBound(object source, System.Web.UI.WebControls.RepeaterItemEventArgs e)

 

{

 

if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))

 

{

 

var Label1 = e.Item.FindControl("Label1") as Label;

 

Label1.Text = e.Item.DataItem.ToString();

 

//Prepare the CheckChange JS function Call

 

 

 

 

var tempstring1 = string.Format("CheckList_CheckChange('{0}');", e.Item.ItemIndex);

 

 

var CheckBoxLit = e.Item.FindControl("litCheckBox") as Literal;

 

 

//The checkbox (can't be ASP.Net checkbox because of changed ClientID)

 

 

 

 

var LitText = @"<input type=""checkbox"" id=""CheckListItems{0}"" name=""CheckListItems"" onclick=""if (RetailerSearchLockItems) return false; {1}"" value=""{2}"" id=""chkItem"" {3} style=""border-style: none;"" />";

 

 

string CheckedText = string.Empty;

 

 

//check the checkboxes based on their viewstate on postback

 

 

 

 

if (this.getCSVofCheckedText().IndexOf("- ALL -") > -1 || this.getCSVofCheckedText().IndexOf(Label1.Text) > -1)

 

{

CheckedText =

"Checked";

 

}

 

//Set the checkbox properties and extra metadata

 

 

 

CheckBoxLit.Text =

string.Format(LitText, e.Item.ItemIndex, tempstring1, e.Item.DataItem.ToString(), CheckedText);

 

 

//Prepare the onclick JS for the hyperlink

 

 

 

 

var tempstring2 = string.Format(

 

 

"if (RetailerSearchLockItems) return false; document.getElementById('{0}{1}').checked = !document.getElementById('{0}{1}').checked; {2}",

 

 

"CheckListItems", e.Item.ItemIndex, tempstring1);

 

 

var CheckboxClicker = e.Item.FindControl("CheckboxClicker") as System.Web.UI.HtmlControls.HtmlAnchor;

 

CheckboxClicker.Attributes.Add(

"onclick", tempstring2);

 

 

}

}

 


Here is an example of the HTML code that repeater spits out for each data item...

<li> 
<input type="checkbox" id="CheckListItems0" name="CheckListItems" onclick="if (RetailerSearchLockItems) return false; CheckList_CheckChange('0');" value="- ALL -" id="chkItem"  style="border-style: none;" />
<a id="ctl00_MainContent_Search2_cboExternalTypes_radComboBox_i0_rptCheckList_ctl00_CheckboxClicker" onclick="if (RetailerSearchLockItems) return false; document.getElementById('CheckListItems0').checked = !document.getElementById('CheckListItems0').checked; CheckList_CheckChange('0');"><span id="ctl00_MainContent_Search2_cboExternalTypes_radComboBox_i0_rptCheckList_ctl00_Label1">- ALL -</span></a>
</li> 

Shawn
Top achievements
Rank 1
 asked on 13 Jan 2009
5 answers
2.1K+ views

Hello,

I would like to enable or disable editing in any given row in a radgrid based upon data values in that same row. I've tried using both ItemCreated and ItemDataBound and am able to see the values for each row in the grid, but I haven't been able to figure out how to access the cell that contains theGridEditCommandColumn and turn it on or off. I've managed to turn the editor on and off for the entire column, but not for individual rows. Also, rather than just not displaying the edit icon, it would be nice to just disable it so it appears grayed out.

Thank you for your help. I'm very new to asp.net and Telerik, but am slowly finding my around.

John

John Mann
Top achievements
Rank 1
 answered on 12 Jan 2009
1 answer
107 views
I have created a template field in a Grid and placed a link button there. Now I am trying to edit the databindings but when I click on Edit DataBindings I get the error message:

"Error invoking '&Edit DataBindings...'. Details: Exception has been thrown by the target of an invocation."

And I do not understand what this means. Any ideas?
Stefan Willebrand
Top achievements
Rank 1
 answered on 12 Jan 2009
6 answers
241 views
Hi,

I have an issue with configurung the RadAjaxManager. I've got a RadGrid which in included in a RadDock and contains a column with a custom delete-button. The page also uses a RadAjaxManagerProxy.
Now, the problem is, that I can't get the AjaxManager configure correctly to update the grid after a record has been deleted.
Here's my AjaxManager configuration:
<AjaxSettings> 
           <telerik:AjaxSetting AjaxControlID="DeleteButton"
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="UserGrid" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
            <telerik:AjaxSetting AjaxControlID="UserGrid"
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="UserGrid" /> 
                </UpdatedControls> 
</telerik:AjaxSetting> 
</AjaxSettings> 
What's wrong with this?

Best regards,
Robert

JEN LA
Top achievements
Rank 1
 answered on 12 Jan 2009
4 answers
82 views
This is more of a "when to do it" rather than a "how to do it" type of question.

I've got some great things going on with the RadGrid control in a SharePoint Application Page.  Being that it's in a SharePoint environment, I'm going to leverage SharePoint Security to show/hide ASP Buttons and ASP LinkButtons within the grid.  When would be the best time to do this?  I'm thinking it would make sense to do this in the PreRender method of the grid.  In PreRender, I'd check what SharePoint groups the currently logged-in user is a member of and then set the Visible property of the corresponding buttons based on that.  Is that the best time to do this?

Thanks,

Eric Skaggs
Eric Skaggs
Top achievements
Rank 2
 answered on 12 Jan 2009
Narrow your results
Selected tags
Tags
+? more
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?