1

I have the following code in a bootstrap table:

<bs:GridView DataSource="{value: TablaGridView}" SortChanged="{command: OrdenaTabla}" class="table table-striped table-bordered table-hover table-full-width">
    <Columns>
        <dot:GridViewTextColumn HeaderText="Nombre" ValueBinding="{value: Nombre}" AllowSorting="True" />
        <dot:GridViewTextColumn HeaderText="Apellido Paterno" ValueBinding="{value: ApellidoPaterno}" AllowSorting="True" />
        <dot:GridViewTextColumn HeaderText="Apellido Materno" ValueBinding="{value: ApellidoMaterno}" AllowSorting="True" />
        <dot:GridViewTextColumn HeaderText="Estado" ValueBinding="{value: Estado}" AllowSorting="True" />
        <dot:GridViewTextColumn HeaderText="RFC" ValueBinding="{value: RFC}" AllowSorting="True" />
        <dot:GridViewTemplateColumn AllowSorting="false">
            <ContentTemplate>
                <dot:Button ButtonTagName="button" class="btn btn-blue show-sv" href="#FormaCliente" data-startFrom="right" Click="{command: _parent.Edit(_this)}">
                    <i class="fa fa-edit"></i> Editar
                </dot:Button>
                &nbsp;&nbsp;&nbsp;
                <dot:Button ButtonTagName="button" class="btn btn-red" Click="{command: _parent.Delete(_this)}">
                    <i class="fa fa-trash-o"></i> Borrar
                </dot:Button>
            </ContentTemplate>
        </dot:GridViewTemplateColumn>
    </Columns>
</bs:GridView>

In the template I have two buttons, which will open a form to edit the data in the table. But I have the problem that the button did not perform the action inside the grid. If I put the button outside the grid performs the action, however inside the grid does nothing. You could help me solve this situation.

regards

UPDATE

This is my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DotVVM.Framework.ViewModel;
using System.Threading.Tasks;
using DotVVM.Framework.Controls.Bootstrap;
using DotVVM.Framework.Controls;

namespace APP_POS.ViewModels
{
    public class TablaViewModel : DotvvmViewModelBase
    {

        private static IQueryable<CustomerData> GetData()
        {
            return new[]
            {
                new CustomerData() { Id = 1, Nombre = "John Doe", RFC = DateTime.Parse("1976-04-01") },
                new CustomerData() { Id = 2, Nombre = "John Deer", RFC = DateTime.Parse("1984-03-02")},
                new CustomerData() { Id = 3, Nombre = "Johnny Walker", RFC = DateTime.Parse("1934-01-03")},
                new CustomerData() { Id = 4, Nombre = "Jim Hacker", RFC = DateTime.Parse("1912-11-04")},
                new CustomerData() { Id = 5, Nombre = "Joe E. Brown", RFC = DateTime.Parse("1947-09-05")},
                new CustomerData() { Id = 6, Nombre = "Jim Harris", RFC = DateTime.Parse("1956-07-06") },
                new CustomerData() { Id = 7, Nombre = "J. P. Morgan", RFC = DateTime.Parse("1969-05-07")},
                new CustomerData() { Id = 8, Nombre = "J. R. Ewing", RFC = DateTime.Parse("1987-03-08")},
                new CustomerData() { Id = 9, Nombre = "Jeremy Clarkson", RFC = DateTime.Parse("1994-04-09") },
                new CustomerData() { Id = 10, Nombre = "Jenny Green", RFC = DateTime.Parse("1947-02-10")},
                new CustomerData() { Id = 11, Nombre = "Joseph Blue", RFC = DateTime.Parse("1948-12-11")},
                new CustomerData() { Id = 12, Nombre = "Jack Daniels", RFC = DateTime.Parse("1968-10-12")},
                new CustomerData() { Id = 13, Nombre = "Jackie Chan", RFC = DateTime.Parse("1978-08-13")},
                new CustomerData() { Id = 14, Nombre = "Jasper", RFC = DateTime.Parse("1934-06-14")},
                new CustomerData() { Id = 15, Nombre = "Jumbo", RFC = DateTime.Parse("1965-06-15")},
                new CustomerData() { Id = 16, Nombre = "Junkie Doodle", RFC = DateTime.Parse("1977-05-16")}
            }.AsQueryable();
        }

        public GridViewDataSet<CustomerData> Customers { get; set; }

        public string SelectedSortColumn { get; set; }

        public TablaViewModel()
        {
            // creates new GridViewDataSet and sets PageSize
            Customers = new GridViewDataSet<CustomerData>();
            Customers.PageSize = 10;
        }


        public void Edit(CustomerData customer)
        {
            Customers.EditRowId = customer.Id;
        }


        public void Delete(CustomerData customer)
        {
            Customers.EditRowId = customer.Id;
        }


        public override Task PreRender()
        {
            // fill customers
            if (SelectedSortColumn == "Nombre")
            {
                Customers.LoadFromQueryable(GetData().OrderBy(c => c.Nombre));
            }
            else if (SelectedSortColumn == "RFC")
            {
                Customers.LoadFromQueryable(GetData().OrderBy(c => c.RFC));
            }
            else
            {
                Customers.LoadFromQueryable(GetData());
            }

            CalculaPaginas();
            CalculaRegistros();

            return base.PreRender();
        }


        public void SortCustomers(string column)
        {
            SelectedSortColumn = column;
        }


    }

    public class CustomerData
    {
        public int Id { get; set; }

        public string Nombre { get; set; }

        public DateTime RFC { get; set; }

    }

}
4

0 に答える 0