Hi. I have a RadGrid with a Combobox FilterTemplate
And i want the combobox to have a Defalut value depending on a URL parameter... with this code the combo is selectd right by the parameter, but the Grid is not populated by this filter.
Could yo please help me with this.
Thankss
<
telerik:RadGrid
ID
=
"rgvEquipos"
Width
=
"70%"
DataSourceID
=
"SqlDataSource1"
AllowFilteringByColumn
=
"True"
AllowSorting
=
"True"
AllowPaging
=
"True"
PageSize
=
"30"
runat
=
"server"
AutoGenerateColumns
=
"False"
ShowFooter
=
"true"
OnPreRender
=
"rgvEquipos_PreRender"
ShowStatusBar
=
"true"
EnableLinqExpressions
=
"false"
OnItemDataBound
=
"rgvEquipos_ItemDataBound"
>
<
MasterTableView
DataKeyNames
=
"equipoId"
ShowFooter
=
"true"
>
<
Columns
>
<
telerik:GridBoundColumn
UniqueName
=
"equipoId"
DataField
=
"equipoId"
HeaderText
=
"equipoId"
AllowFiltering
=
"false"
HeaderStyle-Width
=
"80px"
/>
<
telerik:GridBoundColumn
UniqueName
=
"centro"
DataField
=
"centro"
HeaderText
=
"centro"
HeaderStyle-Width
=
"80px"
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"rcbCentro"
DataSourceID
=
"SqlDataSource2"
DataTextField
=
"centro"
DataValueField
=
"centro"
Height
=
"200px"
AppendDataBoundItems
=
"true"
SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("centro").CurrentFilterValue %>'
runat="server" OnClientSelectedIndexChanged="centroIndexChanged">
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"Todos"
/>
</
Items
>
</
telerik:RadComboBox
>
<
telerik:RadScriptBlock
ID
=
"RadScriptBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function centroIndexChanged(sender, args) {
var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
tableView.filter("centro", args.get_item().get_value(), "EqualTo");
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"Denominacion"
DataField
=
"Denominacion"
HeaderText
=
"Denominacion"
AllowFiltering
=
"false"
HeaderStyle-Width
=
"300px"
/>
<
telerik:GridBoundColumn
UniqueName
=
"Ubicacion"
DataField
=
"Ubicacion"
HeaderText
=
"Ubicacion"
AllowFiltering
=
"false"
HeaderStyle-Width
=
"300px"
/>
<
telerik:GridBoundColumn
UniqueName
=
"centroCosto"
DataField
=
"centroCosto"
HeaderText
=
"centroCosto"
AllowFiltering
=
"false"
HeaderStyle-Width
=
"80px"
/>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
....
<
asp:SqlDataSource
ID
=
"SqlDataSource1"
ConnectionString="<%$ ConnectionStrings:PlanMantenimientoConnectionString %>"
ProviderName="System.Data.SqlClient" SelectCommand="SELECT [equipoId], [centro], [activoFijo], [Denominacion], [areaEmpresa], [Ubicacion], [GP], [fabricante], [tipoObjeto], [numSerie], [statusSistema], [centroCosto], [calle], [creadoEl], [creadoPor] FROM [inventarioPM] WHERE (calle LIKE '%TRANSMIS%' OR calle = '') AND Ubicacion NOT LIKE '%ERO%' AND GP <> ' '"
runat="server"></
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataSource2"
ConnectionString="<%$ ConnectionStrings:PlanMantenimientoConnectionString %>"
ProviderName="System.Data.SqlClient" SelectCommand="SELECT DISTINCT [centro] FROM [inventarioPM] WHERE (calle LIKE '%TRANSMIS%' OR calle = '') AND Ubicacion NOT LIKE '%ERO%' AND GP <> ' ' Order By Centro"
runat="server"></
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataSource3"
ConnectionString="<%$ ConnectionStrings:PlanMantenimientoConnectionString %>"
ProviderName="System.Data.SqlClient" SelectCommand="SELECT DISTINCT [GP] FROM [inventarioPM] WHERE (calle LIKE '%TRANSMIS%' OR calle = '') AND Ubicacion NOT LIKE '%ERO%' AND GP <> ' ' Order By GP"
runat="server"></
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataSource4"
ConnectionString="<%$ ConnectionStrings:PlanMantenimientoConnectionString %>"
ProviderName="System.Data.SqlClient" SelectCommand="SELECT DISTINCT [activoFijo] FROM [inventarioPM] WHERE (calle LIKE '%TRANSMIS%' OR calle = '') AND Ubicacion NOT LIKE '%ERO%' AND activoFijo = 'gggg'"
runat="server"></
asp:SqlDataSource
>
And i want the combobox to have a Defalut value depending on a URL parameter... with this code the combo is selectd right by the parameter, but the Grid is not populated by this filter.
protected
void
Page_Load(
object
sender, EventArgs e)
{
esp = Request[
"esp"
];
zona = Request[
"zona"
];
}
protected
void
rgvEquipos_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridFilteringItem)
{
GridFilteringItem filterItem = (GridFilteringItem)e.Item;
RadComboBox comboCentro = (RadComboBox)filterItem.FindControl(
"rcbCentro"
);
// accessing RadComboBox in FilterTemplate
RadComboBox comboGP = (RadComboBox)filterItem.FindControl(
"rcbGP"
);
// accessing RadComboBox in FilterTemplate
RadComboBox comboActivo = (RadComboBox)filterItem.FindControl(
"rcbactivoFijo"
);
// accessing RadComboBox in FilterTemplate
if
(!IsPostBack)
{
comboCentro.SelectedValue = zona;
comboGP.SelectedValue = esp;
}
}
}
protected
void
rgvEquipos_PreRender(
object
sender, System.EventArgs e)
{
if
(rgvEquipos.MasterTableView.FilterExpression !=
string
.Empty)
{
RefreshCombos();
}
}
protected
void
RefreshCombos()
{
SqlDataSource2.SelectCommand =
"SELECT DISTINCT [centro] FROM [inventarioPM] WHERE (calle LIKE '%TRANSMIS%' OR calle = '') AND Ubicacion NOT LIKE '%ERO%' AND GP <> ' ' AND "
+ rgvEquipos.MasterTableView.FilterExpression.ToString() +
" Order By centro"
;
SqlDataSource3.SelectCommand =
"SELECT DISTINCT [GP] FROM [inventarioPM] WHERE (calle LIKE '%TRANSMIS%' OR calle = '') AND Ubicacion NOT LIKE '%ERO%' AND GP <> ' ' AND "
+ rgvEquipos.MasterTableView.FilterExpression.ToString() +
" Order By GP"
;
SqlDataSource4.SelectCommand = SqlDataSource4.SelectCommand +
" AND "
+ rgvEquipos.MasterTableView.FilterExpression.ToString();
rgvEquipos.MasterTableView.Rebind();
}
Could yo please help me with this.
Thankss