Bootstrap DotVVM GridView的问题

时间:2016-05-03 03:04:22

标签: dotvvm

我在bootstrap表中有以下代码:

<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>

在模板中我有两个按钮,它们将打开一个表格来编辑表格中的数据。但我有问题,按钮没有执行网格内的动作。如果我把按钮放在网格外面执行动作,但是网格内部什么都不做。你可以帮我解决这个问题。

问候

更新

这是我的代码:

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; }

    }

}

0 个答案:

没有答案