Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
117 views
Hi

The below javascript code snippet is not working in firefox but its working in IE.  Through this I am trying to enable/disable few clientselectcolumn of telerik rad grid based on some conditions.

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

{

 

    items[i].get_cell("ClientSelectColumn").disabled = true;

}

 

 

 

dotnet
Top achievements
Rank 1
 answered on 21 Feb 2011
5 answers
179 views
Hi I'm tring to do a disctinct combobox in edit mode in a radgrid but whit no result.
My code is based on the example EditOnDblClick.
Any help would be apreciated.
Thanks in advance

<

 

 

telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" Width="97%" ShowStatusBar="True" AllowSorting="True" PageSize="14" GridLines="None" AllowPaging="True" runat="server" AllowAutomaticUpdates="True" AutoGenerateColumns="False" OnItemDataBound="RadGrid1_ItemDataBound">

 

 

<MasterTableView TableLayout="Fixed" DataKeyNames="nusuario" EditMode="InPlace">
<Columns>
<telerik:GridBoundColumn UniqueName="nusuario" DataField="nusuario" HeaderText="Nusuario" ReadOnly="True" />  

 

 

<telerik:GridBoundColumn UniqueName="nombre" DataField="nombre" HeaderText="Nombre" />

 

<telerik:GridDropDownColumn UniqueName="tipo" HeaderText="Tipo" DataField="tipo" ListTextField="tipo" ListValueField="tipo" DataSourceID="SqlDataSource1" DropDownControlType="RadComboBox" />

 

</Columns>

 

</MasterTableView>

 

<ClientSettings>

 

<ClientEvents OnRowClick="RowClick" OnRowDblClick="RowDblClick" OnGridCreated="GridCreated" OnCommand="GridCommand" />

 

</ClientSettings>

 

</telerik:RadGrid 

<br />

 

<asp:Label ID="Label1" runat="server" EnableViewState="false" />

 

<br />

 

<asp:SqlDataSource ID="SqlDataSource1" runat="server" />

 

 

 

Code

 

 

protected void Page_Load(object sender, EventArgs e)

{

 

 

 

 

SqlDataSource1.ConnectionString = Dynamic.Common.

 

DConfig.ConnectionString;

 

 

 SqlDataSource1.SelectCommand =

 

"SELECT * from usuarios order by nusuario";

 

 

/*

if (DConfig.SelCodNac) AddColumn("codnac");

if (DConfig.SelCodArea) AddColumn("codarea");

if (DConfig.SelCodDel) AddColumn("coddel");

if (DConfig.SelCodMonitor) AddColumn("codmonitor");

*/

 

//Update

 

string sql = string.Empty;

 

foreach (GridColumn column in RadGrid1.MasterTableView.Columns)

{

 

 

if (sql != string.Empty) sql += ",";

sql += column.UniqueName +

 

"=@" + column.UniqueName;

 

 

SqlDataSource1.UpdateParameters.Add(column.UniqueName,

 

string.Empty);

 

 

}

SqlDataSource1.UpdateCommand =

 

"UPDATE usuarios SET " +sql +" WHERE nusuario=@nusuario";

 

 

}

 

 

 

 

protected void RadGrid1_ItemUpdated(object source, Telerik.Web.UI.GridUpdatedEventArgs e)

{

 

 

if (e.Exception != null){

e.KeepInEditMode =

 

true;

 

 

e.ExceptionHandled =

 

true;

 

 

 

SetMessage(Server.HtmlEncode(

 

"Error al actualizar: " + e.Exception.Message).Replace("'", "&#39;").Replace("\r\n", "<br />"));  

 

 

}

 

 

 

else{

 

GridDataItem dataItem = (GridDataItem)e.Item;

SetMessage(

 

" Nusuario " + dataItem.GetDataKeyValue("nusuario") + " updated");

 

 

}

}

 

 

 

private void DisplayMessage(string text)

{

Label1.Text =

 

string.Format("<span>{0}</span>", text);

 

 

}

 

 

 

private void SetMessage(string message)

{

gridMessage = message;

}

 

 

 

 

protected void RadGrid1_DataBound(object sender, EventArgs e)

 

{

 

 

 

if (!string.IsNullOrEmpty(gridMessage)) DisplayMessage(gridMessage);

 

}

 

 

 

protected void AddColumn(string campo)

 

{

 

 

 

//GridBoundColumn

 

 

 

 

GridDropDownColumn boundColumn = new GridDropDownColumn();

 

boundColumn.UniqueName = campo;

boundColumn.HeaderText = campo.Substring(0, 1).ToUpper() + campo.Substring(1);

boundColumn.DataField = campo;

boundColumn.ListTextField=campo;

boundColumn.ListValueField=campo;

boundColumn.DataSourceID =

 

 

"SqlDataSource1";

 

RadGrid1.MasterTableView.Columns.Add(boundColumn);

 

}

 

 

 

 

 

 

 

protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)

 

{

 

 

 

if (e.Item is GridEditableItem && (e.Item as GridEditableItem).IsInEditMode)

 

{

 

 

 

/*

 

GridEditFormItem editform = (GridEditFormItem)e.Item;

DropDownList ddl = (DropDownList)editform.FindControl("ddl");

ddl.Items.Add("foo");

ddl.Items.Add("bar");

*/

 

 

}

}

Daniel
Telerik team
 answered on 21 Feb 2011
3 answers
231 views
Hello,

I am trying to use an Item Template with the Rad Grid but when the control is databound I just get a message saying 'No records to display'.  Here is my code:

ASPX:
<telerik:RadGrid ID="EcsSupplierAgreementsGrid" runat="server" AutoGenerateColumns="false"
               OnNeedDataSource="EcsSupplierAgreementsGrid_NeedDataSource"
               GridLines="None">
               <MasterTableView Width="100%">
                   <ItemTemplate>
                       <%# Eval("SupplierCode")%>
                   </ItemTemplate>
               </MasterTableView>
           </telerik:RadGrid>

ASPX.CS:
protected void EcsSupplierAgreementsGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
  EcsSupplierAgreementsGrid.DataSource = _agreement.SupplierAgreements;
}

The datasource is an IList<T>.  When I debug the line above I can see that the collection has 2 records in it.

Please can you tell me what I am doing wrong.

Thanks
Princy
Top achievements
Rank 2
 answered on 21 Feb 2011
3 answers
112 views
Hi ,

I want to use TreeList on a page. I have some questions about the TreeList control.
1. I want to add a filter for the treelist,just like the filter for RadGrid. How to achieve that?
2. I put a TemplateColumn in the treelist, and I want to display a hyper link in for a column, as 
<telerik:radtreelist id="EntityGrid" runat="server" autogeneratecolumns="false" datakeynames="RecordID"
                parentdatakeynames="ParentID">
            <Columns>
                <telerik:TreeListTemplateColumn UniqueName="ImageHLColHeader" HeaderText="">
                <ItemTemplate>
                    <asp:HyperLink ID="imageHLCol" runat="server" NavigateUrl=<%# Eval("NavURL") %> ImageUrl=<%# Eval("NavImageURL") %> ></asp:HyperLink>
                </ItemTemplate>
                <HeaderStyle Width="35px" />
                </telerik:TreeListTemplateColumn>
            </Columns>
            </telerik:radtreelist>

But the column could not be displayed. It always show empty column in the UI. No  hyperlink is shown up. Seems like the hyperlink is ignored. I even try:
 <ItemTemplate>
                    <%# Eval("RecordID") %>
                </ItemTemplate>

But still could not see anything shown up in the UI. What's wrong?

3. I changed the itemTemplate as
<asp:HyperLink ID="imageHLCol" runat="server"></asp:HyperLink>
and I want to set the navigateURL and ImageURL when the event ItemDataBound is triggered. But I could not find the hyperLink control in that event.
TryCast(e.Item, TreeListDataItem)("ImageHLColHeader").FindControl("imageHLCol") always return nothing. What's wrong? 
Need urgent help. Thank you very very very much.
zxp
Top achievements
Rank 1
 answered on 21 Feb 2011
1 answer
177 views
Hi team,
hyperlink inside gridRow gets active even if gridRow.Enabled=false
Is there any setting for deactivate hyperlink in radgrid.
Princy
Top achievements
Rank 2
 answered on 21 Feb 2011
1 answer
85 views
Hi
I have the following within a RadGrid

<telerik:GridTemplateColumn Visible="False" DataField="fk_project_id" DataType="System.Int64" FilterControlAltText="Filter fk_project_id column" HeaderText="Project" SortExpression="fk_project_id" UniqueName="fk_project_id">
                    <EditItemTemplate>
                        <telerik:RadComboBox ID="fk_project_idRadComboBox" runat="server" DataSourceID="sdsProjects" EmptyMessage="begin typing project# or name" AllowCustomText="true" Width="300px" Filter="contains"
                             DataTextField="project_full" DataValueField="id" SelectedValue='<%# Bind("fk_project_id") %>'>
                        </telerik:RadComboBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="fk_project_idLabel" runat="server" Text='<%# Eval("fk_project_id") %>'></asp:Label>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>

Im using a SqlDataSource to perform the insert but I cant seem to get the value from the radComboBox to perform the insert.
Here is the code from the Insert Parameter section
<asp:ControlParameter ControlID="fk_project_idRadComboBox" PropertyName="DataValueField" Name="fk_project_id" DbType="Int32" /> 

should I not be using a control parameter here to get at the value?           
Any help would be greatly appreciated.
Thanks
Alex
Princy
Top achievements
Rank 2
 answered on 21 Feb 2011
1 answer
328 views
hello,

How to manupulated the height of Filter row which contain the filter textbox in RadGrid.
I hope, property could change the heigth. But I dont know how to do.



Thanks You


Best Regards
Jiten Kumar


Shinu
Top achievements
Rank 2
 answered on 21 Feb 2011
1 answer
209 views
Hi,

I want to create a grid which sets all the records in Edit mode when the page is loaded. I use "In=place" edit mode. I do it following the codes (the same way as instructed from page http://www.telerik.com/help/aspnet/grid/grddefaulteditmodeforgriditemsoninitialload.html or page http://www.telerik.com/help/aspnet-ajax/grdputallitemsineditmodenoadditionalrebind.html)

protected void Page_Load(object sender, EventArgs e)
   {
        
for (int i = 0; i < RadGrid1.PageSize; i++)
       {
           RadGrid1.EditIndexes.Add(i);
       }
   }


OR

private void RadGrid1_PreRender(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
 
foreach(GridItem item in RadGrid1.MasterTableView.Items)
 {
  
if (item is GridEditableItem)
  {
   GridEditableItem editableItem= item
as GridDataItem;
   editableItem.Edit = true;
  }
 }
 RadGrid1.Rebind();
}


The grid works fine om the first page load, but both of the above approaches fail when any postback happens (i.e. when users change to the next page).

So how could I handle the postback event so that all records, for example of the next page, are still in Edit mode after postback?

Regards,

Quan


Princy
Top achievements
Rank 2
 answered on 21 Feb 2011
5 answers
148 views

I have a RadScheduler populated via an SqlDataSource

The SELECT statement on the data source is this.

SqlDataSource1.SelectCommand = "SELECT * FROM [Activity] WHERE act_Rep_ID = " + ScheduleUserID.ToString();

Simple stuff.

Now in the AppointmentDateBound event I am trying to set a different color to the appointment, based on a certain value that should be in the appointment thanks to the SELECT * query in the SqlDataSource.

In this example you can see my test code where I just test the 'Subject'.

protected void RadScheduler1_AppointmentDataBound(object sender, Telerik.Web.UI.SchedulerEventArgs e)
     {
         Appointment a = e.Appointment;
    
         if (a.Subject == "Phone Call")
         {
             a.BackColor = System.Drawing.Color.Yellow;
             a.BorderColor = System.Drawing.Color.Red;
             a.BorderStyle = BorderStyle.Dotted;
             a.BorderWidth = Unit.Pixel(2);
         }
     }


The value I need however is a value that is in the Activity table, but is not listed as a property of the appointment object.

In fact, the appointment object only holds a fraction of the values from each Activity table row.

How do I get to all the other values that this SqlDataSource would be holding ?
Brad
Top achievements
Rank 1
 answered on 21 Feb 2011
1 answer
45 views
I'd like to have a grid of images, say 4x4. And then drag'n'drop to sort the images. Could I use Telerik controls to achieve this functionality.
Julian Roberts
Top achievements
Rank 1
 answered on 20 Feb 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?