Gridview - Rows with Checkbox

  1. #1

    [CLOSED] Gridview - Rows with Checkbox

    Good morning,

    I am working in a gridview with the following structure:



    My problem is how to add a checkbox to every row ( in red ).

    This is the code:

    <%@ Page Language="C#" %>
    
    <%@ Import Namespace="System.Globalization" %>
    <%@ Import Namespace="System.Collections.Generic" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Resultados.DataSource = new List<Project> 
             {
                 new Project("Obra A","Artigo1","Descricao","Documento",23.4,2,1,23.4),
                 new Project("Obra A","Artigo2","Descricao","Documento",23.1,1,3,23.2),
                 new Project("Obra B","Artigo3","Descricao","Documento",23.1,1,3,23.2),
                 new Project("Obra B","Artigo4","Descricao","Documento",23.1,1,3,23.2)
             };
    
            this.Resultados.DataBind();
        }
    
        public class Project
        {
            public Project(string Obra, string Artigo, string Descricao, string Documento, double PrecoUnit, int Quantd, double UN, double VLiquido)
            {
                this.Obra = Obra;
                this.Artigo = Artigo;
                this.Descricao = Descricao;
                this.Documento = Documento;
                this.PrecoUnit = PrecoUnit;
                this.Quantd = Quantd;
                this.UN = UN;
                this.VLiquido = VLiquido;
            }
    
            public string Obra { get; set; }
            public string Artigo { get; set; }
            public string Descricao { get; set; }
            public string Documento { get; set; }
            public double PrecoUnit { get; set; }
            public int Quantd { get; set; }
            public double UN { get; set; }
            public double VLiquido { get; set; }
        }
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Store ID="Resultados" runat="server" GroupField="Obra">
            <SortInfo Direction="ASC" Field="Artigo" />
            <Reader>
                <ext:JsonReader IDProperty="Artigo">
                    <Fields>
                        <ext:RecordField Name="Obra" />
                        <ext:RecordField Name="Artigo" />
                        <ext:RecordField Name="Descricao" />
                        <ext:RecordField Name="Documento" />
                        <ext:RecordField Name="PrecoUnit" />
                        <ext:RecordField Name="Quantd" />
                        <ext:RecordField Name="UN" />
                        <ext:RecordField Name="VLiquido" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
        </ext:Store>
        <ext:GridPanel ID="GridPanel1" runat="server" Frame="true" StoreID="Resultados" StripeRows="true"
            Title="Mapa Comparativo de Fornecimentos" AutoExpandColumn="Obra" Collapsible="true"
            AnimCollapse="false" Icon="ApplicationViewColumns" TrackMouseOver="false" Width="800"
            Height="450" ClicksToEdit="1">
            <ColumnModel ID="ColumnModel1" runat="server">
                <Columns>
                <ext:Column ColumnID="Artigo" Header="Artigo" Sortable="true" DataIndex="Artigo"
                        Hideable="false" />
                    <ext:Column ColumnID="Obra" Header="Obra" DataIndex="Obra">
                    </ext:Column>
                    
                    <ext:Column ColumnID="Descricao" Header="Descrição" DataIndex="Descricao" Width="20" />
                    <ext:Column ColumnID="Documento" Width="25" Header="Documento" Sortable="true" DataIndex="Documento" />
                    <ext:Column Width="20" ColumnID="PrecoUnit" Header="Preço Unit." Sortable="true"
                        DataIndex="PrecoUnit" />
                    <ext:Column Width="20" ColumnID="Quantd" Header="Quantd." Sortable="true" DataIndex="Quantd" />
                    <ext:Column Width="20" ColumnID="UN" Header="UN" Sortable="false" Groupable="false"
                        DataIndex="UN" />
                    <ext:Column ColumnID="VLiquido" Header="V. Líquido" />
                </Columns>
            </ColumnModel>
    
            <View>
                <ext:GroupingView ID="GroupingView1" runat="server" ForceFit="true" MarkDirty="false"
                    ShowGroupName="false" EnableNoGroups="true" HideGroupedColumn="true" />
            </View>
    
        </ext:GridPanel>
        </form>
    </body>
    </html>
    I hope I've explained myself properly.

    Thank you.
    Last edited by FilipeCosta; Nov 17, 2010 at 10:36 AM.
  2. #2
    Hi,

    Use CheckColumn
  3. #3
    Quote Originally Posted by Vladimir View Post
    Hi,

    Use CheckColumn
    Hello,

    I added the checkColumn and after that all the rows disapear, so with that solution at the moment is not working. :\
  4. #4
    Hi,

    Please provide your test sample
  5. #5
    The store:
    <ext:Store ID="Resultados" runat="server" GroupField="Obra">
            <SortInfo Direction="ASC" Field="Artigo" />
            <Reader>
                <ext:JsonReader IDProperty="Artigo">
                    <Fields>
                        <ext:RecordField Name="Obra" />
                        <ext:RecordField Name="Artigo" />
                        <ext:RecordField Name="Descricao" />
                        <ext:RecordField Name="Documento" />
                        <ext:RecordField Name="PrecoUnit" />
                        <ext:RecordField Name="Quantd" />
                        <ext:RecordField Name="UN" />
                        <ext:RecordField Name="VLiquido" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
        </ext:Store>
    The grid:
        <ext:GridPanel ID="GridResultados" runat="server" Frame="true" StoreID="Resultados" StripeRows="true"
            Title="Mapa Comparativo de Fornecimentos" AutoExpandColumn="Obra" Collapsible="true"
            AnimCollapse="false" Icon="ApplicationViewColumns" TrackMouseOver="false" Width="800"
            Height="450" ClicksToEdit="1">
            <ColumnModel ID="ColumnModel1" runat="server">
                <Columns>
                    <ext:Column ColumnID="Obra" Header="Obra" DataIndex="Obra">
                    </ext:Column>
                    <ext:Column ColumnID="Artigo" Header="Artigo" Sortable="true" DataIndex="Artigo"
                        Hideable="false" />
                    <ext:Column ColumnID="Descricao" Header="Descrição" DataIndex="Descricao" Width="20" />
                    <ext:Column ColumnID="Documento" Width="25" Header="Documento" Sortable="true" DataIndex="Documento" />
                    <ext:Column Width="20" ColumnID="PrecoUnit" Header="Preço Unit." Sortable="true"
                        DataIndex="PrecoUnit" />
                    <ext:Column Width="20" ColumnID="Quantd" Header="Quantd." Sortable="true" DataIndex="Quantd" />
                    <ext:Column Width="20" ColumnID="UN" Header="UN" Sortable="false" Groupable="false"
                        DataIndex="UN" />
                    <ext:Column ColumnID="VLiquido" Header="V. Líquido" />
                    <ext:CheckColumn/>
                </Columns>
            </ColumnModel>
            <View>
                <ext:GroupingView ID="GroupingView1" runat="server" ForceFit="true" MarkDirty="false"
                    ShowGroupName="false" EnableNoGroups="true" HideGroupedColumn="true" >
                </ext:GroupingView>
            </View>
        </ext:GridPanel>
  6. #6
    Hi,

    You have to define DataIndex for CheckColumn
  7. #7
    Now they appear, but they are all uneditable. I cannot change the checked or unchecked. :(
  8. #8
    Hi,

    Set Editable="true" for the column
  9. #9
    Now all working!

    Thanks for the support Vladimir! ;)

Similar Threads

  1. CheckBox Update Problem in Gridview.
    By Ganesh3.shirsath in forum 1.x Help
    Replies: 0
    Last Post: Jan 07, 2011, 9:03 AM
  2. [CLOSED] Default selected checkbox in gridview
    By speedstepmem3 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Aug 06, 2010, 10:57 AM
  3. [CLOSED] GridView select only edited or inserted rows
    By GmServizi in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 06, 2009, 4:46 AM
  4. Replies: 0
    Last Post: Jul 07, 2009, 2:22 PM
  5. [CLOSED] Checkbox in Gridview
    By caiomarques in forum 1.x Help
    Replies: 4
    Last Post: Oct 06, 2008, 4:34 PM

Tags for this Thread

Posting Permissions