<
telerik:RadGrid
runat
=
"server"
ID
=
"view"
ShowStatusBar
=
"true"
AutoGenerateColumns
=
"false"
Visible
=
"false"
>
<
ClientSettings
>
<
Selecting
AllowRowSelect
=
"True"
/>
</
ClientSettings
>
<
GroupingSettings
CaseSensitive
=
"false"
/>
<
MasterTableView
ShowHeadersWhenNoRecords
=
"true"
DataKeyNames
=
"Id"
ClientDataKeyNames
=
"Id"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"Name"
UniqueName
=
"Name"
HeaderText
=
"User Name"
AutoPostBackOnFilter
=
"true"
Visible
=
"true"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Phone"
UniqueName
=
"Phone"
HeaderText
=
"User Phone"
AutoPostBackOnFilter
=
"true"
Visible
=
"true"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Email"
UniqueName
=
"Email"
HeaderText
=
"User Email"
AutoPostBackOnFilter
=
"true"
Visible
=
"true"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
<
br
/>
<
telerik:RadGrid
runat
=
"server"
ID
=
"view2"
ShowStatusBar
=
"true"
Visible
=
"true"
>
<
ClientSettings
>
<
Selecting
AllowRowSelect
=
"True"
/>
</
ClientSettings
>
<
GroupingSettings
CaseSensitive
=
"false"
/>
<
MasterTableView
ShowHeader
=
"false"
>
</
MasterTableView
>
</
telerik:RadGrid
>
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BindGridView();
}
}
private DataTable PivotTable(DataTable origTable)
{
DataTable newTable = new DataTable();
DataRow dr = null;
//Add Columns to new Table
for (int i = 0; i <= origTable.Rows.Count; i++)
{
newTable.Columns.Add(new DataColumn(origTable.Columns[i].ColumnName, typeof(String)));
}
//Execute the Pivot Method
for (int cols = 0; cols <
origTable.Columns.Count
; cols++)
{
dr
=
newTable
.NewRow();
for (int
rows
=
0
; rows < origTable.Rows.Count; rows++)
{
if (rows < origTable.Columns.Count)
{
dr[0] = origTable.Columns[cols].ColumnName; // Add the Column Name in the first Column
dr[rows + 1] = origTable.Rows[rows][cols];
}
}
newTable.Rows.Add(dr); //add the DataRow to the new Table rows collection
}
return newTable;
}
private void BindGridView()
{
String
str
=
Request
.RawUrl;
if (!IsPostBack)
{
if (str.Contains("?a"))
{
Int32
url_id
=
Convert
.ToInt32(Request.Params["a"]);
user_id
=
url_id
;
DataTable
dt
=
new
DataTable();
SqlConnection
cn
=
new
SqlConnection("");
SqlCommand
cmd
=
new
SqlCommand("user_data", cn);
cmd.Parameters.Add(new SqlParameter("@id", SqlDbType.Int));
cmd.Parameters["@id"]
.Value
=
url_id
;
cmd.CommandType
= CommandType.StoredProcedure;
SqlDataAdapter
sqlDa
=
new
SqlDataAdapter(cmd);
sqlDa.Fill(dt);
try
{
cn.Open();
if (dt.Rows.Count > 0)
{
//Bind the First GridView with the original data from the DataTable
view.DataSource = dt;
view.DataBind();
//Pivot the Original data from the DataTable by calling the
//method PivotTable and pass the dt as the parameter
DataTable pivotedTable = PivotTable(dt);
view2.DataSource = pivotedTable;
view2.DataBind();
}
}
catch (SqlException ex)
{
//...
}
finally
{
if (cn.State != ConnectionState.Closed)
{
cn.Close();
cmd.Parameters.Clear();
}
}
}
}
}
Protected
Sub
rdGridUDFRule_ItemDataBound(
ByVal
sender
As
Object
,
ByVal
e
As
Telerik.Web.UI.GridItemEventArgs)
Handles
rdGridUDFRule.ItemDataBound
If
TypeOf
e.Item
Is
Telerik.Web.UI.GridEditFormItem
And
e.Item.IsInEditMode
Then
If
e.Item.OwnerTableView.IsItemInserted
Then
'item is about to be inserted
For
Each
editItem
As
Telerik.Web.UI.GridEditFormItem
In
rdGridUDFRule.MasterTableView.GetItems(Telerik.Web.UI.GridItemType.EditFormItem)
If
(editItem.IsInEditMode)
Then
Dim
plcHolder
As
HtmlTableCell =
DirectCast
(editITem.FindControl(
"placeHolderRadGridFormTemplate"
), HtmlTableCell)
Dim
objDynamicTxt
As
New
TextBox
objDynamicTxt.ID =
"DynamicControl"
objDynamicTxt.MaxLength = intLength
plcHolder.Controls.Add(objDynamicTxt)
End
If
Next
Else
'item is about to be edited
Dim
editedItem
As
Telerik.Web.UI.GridEditableItem = TryCast(e.Item, Telerik.Web.UI.GridEditableItem)
End
If
End
If
End
Sub
Retrieve Dynamic control values from server side sample code
Protected
Sub
RadGrid1_UpdateCommand(
ByVal
sender
As
Object
,
ByVal
e
As
GridCommandEventArgs)
Handles
rdGridUDFRule.UpdateCommand
If
(e.CommandName = RadGrid.UpdateCommandName)
Then
For
Each
editItem
As
Telerik.Web.UI.GridEditFormItem
In
rdGridUDFRule.MasterTableView.GetItems(Telerik.Web.UI.GridItemType.EditFormItem)
If
(editItem.IsInEditMode)
Then
Dim
plcHolder
As
HtmlTableCell =
DirectCast
(editITem.FindControl(
"placeHolderRadGridFormTemplate"
), HtmlTableCell)
Dim
objDynamicTxt
As
TextBox =
DirectCast
(plcHolder.FindControl(
"DynamicControl"
)
'******************************* THE objDynamicTxt RETURN NOTHING *******************************
End
If
Next
End
If
End
Sub
I am creating a Dynamically built RadGrid. I have to do so because I am generating columns based on how many dates my sql query returns. I am placing the specific dates as header column groups. Under each date I am trying to create a dropdowncolumn that has a different datasource than the radGrid.
The problem is creating it dynamically. I thought about using an item template but how could I place a dropdown in the item template for each drop down that i need to create, which is two per date.
How do i bind the datasource for the DropDownColumn from code behind when the entire grid is dynamically built.
for (int t = 0; t < datecount; t++)
{
int utacount = Convert.ToInt32(getDrill.Rows[t][3].ToString());
for (int p = 0; p < datecount; p++)
{
GridDropDownColumn ddc = new GridDropDownColumn();
int b = p + 1;
ddc.UniqueName = "ddc" + p + s;
if (p - 1 < utacount)
{
string name = "uta" + p + s;
ddc.ColumnGroupName = name;
//ddc.DataField = "strStatus";
//ddc.ListTextField = "strStatus";
////GridEditableItem editedItem = ddc as GridEditableItem;
////GridEditManager editman = editedItem.EditManager;
////GridDropDownColumnEditor editor = editman.GetColumnEditor(name) as GridDropDownColumnEditor;
////editor.DataSource = getDrill;
////editor.DataBind();
}
grid.MasterTableView.Columns.Add(ddc);
}
s++;
}
<telerik:RadGrid ID="RadGrid1" AllowMultiRowSelection="True" runat="server" AutoGenerateColumns="False" GridLines="None" >
<
MasterTableView >
<Columns>
<telerik:GridBoundColumn DataField="INVOICE" UniqueName="INVOICE"
HeaderText="Invoice">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="DATE" UniqueName="DATE" HeaderText="Date">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="BOL" UniqueName="BOL" HeaderText="BOL">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="PO" UniqueName="PO" HeaderText="PO">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="POHIDE" UniqueName="POHIDE" Visible="false"
HeaderText="PO Hide" >
</telerik:GridBoundColumn>
</Columns>
</
MasterTableView>
<ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="True" >
<Selecting AllowRowSelect="True" />
</ClientSettings>
</telerik:RadGrid>
I have tried using the RadGrid1_ColumnCreated event but no luck. How do I change the column width at binding time?
Thanks
John
Hi,
Is there a way to disable the RadGrid filter TextBox while keeping the filter button active and visible? I'm using the button as a combo box and no longer need the TextBox. Thanks for your help!
Hi,
I am Unable to export image of RadHtmlcHart in ie 9 [ Compatibility mode ] using RadClientExportManager. Please find the attachment. It works fine for other versions except ie 8 & 9 [ Compatibility mode ] .
Regards,
Chethan Y
Unfortunately, the Telerik skins don't specify a text color ​for each and every HTML element of the scheduler.
For example, the default styling for the H2 element in the scheduler header seems to be:
.RadScheduler .rsHeader h
2
{
font-size
:
15px
;
font-weight
:
normal
;
line-height
:
30px
;
text-indent
:
43px
;
height
:
30px
;
display
:
block
;
overflow
:
hidden
;
}
So now the scheduler picks up whatever color for eg. H2 elements is generally specified in the website, which might not be a suitable color for the scheduler at all.​
I understand that I can overrule this in a specific website. But I would like a consistent look of the scheduler elements, regardless of the website styles at hand.
Can you please add default coloring to all control elements in the Telerik control skins?