jueves, 21 de abril de 2016
C# - checkbox, marcar o desmarcar todo
--control con evento (ASPX)
_________________________________________
<dx:ASPxCheckBox ID="chkTodosOp" runat="server" CheckState="Unchecked" Text="Todos Seleccionados"
ValueChecked="1" ValueType="System.Int32" ValueUnchecked="0">
<ClientSideEvents CheckedChanged="function(s,e){SeleccionarTodos(s, e);}"></ClientSideEvents>
</dx:ASPxCheckBox>
--Llamada (Javascript)
_________________________________________
function SeleccionarTodos(s, e) {
CallBackMain.PerformCallback(s.GetValue() + ',CheckedAll');
}
--Ejecución (.CS)
_________________________________________
#region SELECCIONAR TODOS
if (e.Parameter != null && e.Parameter.Contains(",") &&
e.Parameter.Split(',')[1].ToString().Trim() == "CheckedAll")
{
var chkSelectAll = e.Parameter.Split(',')[0];
if (gvListaOperaciones.VisibleRowCount > 0)
{
for (int i = 0; i < gvListaOperaciones.VisibleRowCount; i++)
{
var dataCheckBox = gvListaOperaciones.Columns[""] as GridViewDataCheckColumn;
var chk = (ASPxCheckBox)gvListaOperaciones.FindRowCellTemplateControl(i, dataCheckBox, "chkDetalle");
if (Convert.ToInt32(chkSelectAll) == 1)
{
chk.Checked = true;
}
else
{
chk.Checked = false;
limpiaGrillaBienes();
}
}
}
}
#endregion
--GRILA (.ASPX)
_________________________________________
<dx:ASPxGridView ID="gvListaOperaciones" ClientInstanceName="gvListaOperaciones"
runat="server" DataSourceID="ObjectSourceListaOperaciones" Width="100%" KeyFieldName="operacion"
SettingsBehavior-AllowSort="False" Visible="true">
<%-- <ClientSideEvents RowDblClick="function(s, e) { RowDblClik(s, e); }" EndCallback="function(s, e) { OnEndCallback(s, e); }">
</ClientSideEvents>--%>
<SettingsBehavior AllowDragDrop="false" AllowFocusedRow="True" />
<SettingsEditing Mode="Inline" />
<Settings ShowFooter="True" ShowHorizontalScrollBar="True" ShowVerticalScrollBar="True"
VerticalScrollableHeight="200" />
<SettingsLoadingPanel Text="Cargando..." />
<ClientSideEvents RowDblClick="function(s, e) { RowDblClik(s, e); }" EndCallback="function(s, e) { OnEndCallback(s, e); }" />
<Columns>
<dx:GridViewDataCheckColumn FieldName="" VisibleIndex="0" Caption="" Width="55">
<DataItemTemplate>
<dx:ASPxCheckBox ID="chkDetalle" runat="server" ValueChecked="1" ValueType="System.Int32"
ValueUnchecked="0">
<ClientSideEvents CheckedChanged="function(s, e) {CallBackMain.PerformCallback('R');}" />
</dx:ASPxCheckBox>
</DataItemTemplate>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<CellStyle HorizontalAlign="Center">
</CellStyle>
<PropertiesCheckEdit ValueType="System.Int16" ValueChecked="1" ValueUnchecked="0">
</PropertiesCheckEdit>
</dx:GridViewDataCheckColumn>
<dx:GridViewDataColumn FieldName="operacion" VisibleIndex="0" Width="100px" Caption="Operación"
ReadOnly="true" HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<CellStyle HorizontalAlign="Center">
</CellStyle>
</dx:GridViewDataColumn>
<dx:GridViewDataColumn FieldName="estado" VisibleIndex="1" Caption="Estado" Width="100px"
ReadOnly="true" HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<CellStyle HorizontalAlign="Center">
</CellStyle>
</dx:GridViewDataColumn>
<dx:GridViewDataColumn FieldName="fecha_ingreso_cont" VisibleIndex="2" Width="150px"
Caption="Fecha Ing.Contrato" ReadOnly="true" HeaderStyle-HorizontalAlign="Center"
CellStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<CellStyle HorizontalAlign="Center">
</CellStyle>
</dx:GridViewDataColumn>
<dx:GridViewDataColumn FieldName="fecha_opc" Width="150px" VisibleIndex="3" Caption="Fecha Op.Compra"
ReadOnly="true" HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<CellStyle HorizontalAlign="Center">
</CellStyle>
</dx:GridViewDataColumn>
<dx:GridViewDataColumn FieldName="rut_cliente" Width="100px" VisibleIndex="4"
Caption="Rut Cliente" ReadOnly="true" HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<CellStyle HorizontalAlign="Center">
</CellStyle>
</dx:GridViewDataColumn>
<dx:GridViewDataColumn FieldName="nom_cliente" Width="200px" VisibleIndex="5" Caption="Nom. Cliente" ReadOnly="true" HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<CellStyle HorizontalAlign="Center">
</CellStyle>
</dx:GridViewDataColumn>
<dx:GridViewDataColumn FieldName="cod_mat" Width="80px" Caption="Cod. Mat" ReadOnly="true" Visible="false" HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<CellStyle HorizontalAlign="Center">
</CellStyle>
</dx:GridViewDataColumn>
<dx:GridViewDataColumn FieldName="" Width="100%" Caption="" VisibleIndex="6" ReadOnly="true" HeaderStyle-HorizontalAlign="Center" CellStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<CellStyle HorizontalAlign="Center">
</CellStyle>
</dx:GridViewDataColumn>
</Columns>
<SettingsBehavior AllowDragDrop="False" AllowSort="False" AllowFocusedRow="True">
</SettingsBehavior>
<SettingsPager Visible="true" Mode="ShowPager" PageSize="1000" />
<SettingsEditing Mode="Inline"></SettingsEditing>
<Settings ShowFooter="True" ShowVerticalScrollBar="True" ShowHorizontalScrollBar="True">
</Settings>
<SettingsLoadingPanel Text="Cargando..."></SettingsLoadingPanel>
<ImagesEditors>
<CheckBoxChecked Height="15px" Url="../../../img/icon/accept.png" Width="15px">
</CheckBoxChecked>
<CheckBoxUnchecked Height="15px" Url="../../../img/icon/ico-chec.png" Width="15px">
</CheckBoxUnchecked>
</ImagesEditors>
</dx:ASPxGridView>
Etiquetas:
checkbox,
chk,
desmarcar,
marcar,
marcar todo,
seleccionar todo
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario