public override void Refresh() { base.Refresh(); //rebuild data grid Grid = new ObjectGrid(); Grid.DataSource = DataSource; Grid.DataBind(); //add New button IButton newRecord = Platform.Current.Create<IButton>(); newRecord.Text = Resources.Strings.OKHOSTING_ORM_UI_SelectController_New; newRecord.Click += NewRecord_Click; //create our own grid IGrid container = Platform.Current.Create<IGrid>(); container.ColumnCount = 1; container.RowCount = 2; container.SetContent(0, 0, Grid.Content); container.SetContent(1, 0, newRecord); Platform.Current.Page.Title = Resources.Strings.OKHOSTING_ORM_UI_SelectController_List + ' ' + Translator.Translate(DataSource.DataType.InnerType); Platform.Current.Page.Content = container; }
/// <summary> /// Starts this instance and call the method sends Refresh (). /// </summary> /// <summary xml:alng="es"> /// Inicia esta instancia y manda llamar al metodo Refresh(). /// </summary> public override void Start() { base.Start(); Grid = new ObjectGrid(); Grid.Sorted += Grid_Sorted; SelectChecks = new List<ICheckBox>(); lblTotal = Platform.Current.Create<ILabel>(); //page size ILabel lblPageSize = Platform.Current.Create<ILabel>(); lblPageSize.Text = "Page size:"; IListPicker lstPageSize = Platform.Current.Create<IListPicker>(); lstPageSize.Items = new List<string>() { "20", "50", "100", "200", "500", "1000" }; lstPageSize.Value = "20"; lstPageSize.ValueChanged += LstPageSize_ValueChanged; //current page ILabel lblCurrentPage = Platform.Current.Create<ILabel>(); lblCurrentPage.Text = "Current page:"; lstCurrentPage = Platform.Current.Create<IListPicker>(); lstCurrentPage.ValueChanged += LstCurrentPage_ValueChanged; //add New button IListPicker cmdNewRecord = Platform.Current.Create<IListPicker>(); cmdNewRecord.Items = new List<string>(); cmdNewRecord.Items.Add(Resources.Strings.OKHOSTING_ORM_UI_SelectController_New); cmdNewRecord.Items.Add(Translator.Translate(DataSource.DataType.InnerType)); foreach(DataType dtype in DataSource.DataType.SubDataTypesRecursive) { cmdNewRecord.Items.Add(Translator.Translate(dtype.InnerType)); } cmdNewRecord.ValueChanged += cmdNewRecord_ValueChanged; //add Back button IButton cmdBack = Platform.Current.Create<IButton>(); cmdBack.Text = Resources.Strings.OKHOSTING_ORM_UI_SelectController_Back; cmdBack.Click += Back_Click; //grid.content is created here Refresh(); //now create the filters form with the same number of columns as the grid frmFilters = new FilterDataForm(); frmFilters.RepeatColumns = Grid.DataSource.Members.Count; foreach (var memberInfo in DataSource.DataType.AllMemberInfos) { frmFilters.AddFields(memberInfo); } frmFilters.DataBind(); foreach (Filters.Filter filter in DataSource.Where) { frmFilters.ApplyFilter(filter); } //buton to apply filter IButton cmdRefresh = Platform.Current.Create<IButton>(); cmdRefresh.Text = "Refresh"; cmdRefresh.Click += cmdFilter_Click; //buton to delete selected objects IButton cmdDelete = Platform.Current.Create<IButton>(); cmdDelete.Text = "Delete"; cmdDelete.Click += cmdDelete_Click; //create our own grid IGrid container = Platform.Current.Create<IGrid>(); container.ColumnCount = 9; container.RowCount = 4; container.SetContent(0, 0, frmFilters.Content); container.SetColumnSpan(7, frmFilters.Content); container.SetContent(2, 0, cmdRefresh); container.SetContent(2, 1, cmdNewRecord); container.SetContent(2, 2, cmdBack); container.SetContent(2, 3, cmdDelete); container.SetContent(2, 4, lblPageSize); container.SetContent(2, 5, lstPageSize); container.SetContent(2, 6, lblCurrentPage); container.SetContent(2, 7, lstCurrentPage); container.SetContent(2, 8, lblTotal); container.SetContent(3, 0, Grid.Content); container.SetColumnSpan(container.ColumnCount, Grid.Content); Platform.Current.Page.Title = Resources.Strings.OKHOSTING_ORM_UI_SelectController_List + ' ' + Translator.Translate(DataSource.DataType.InnerType); Platform.Current.Page.Content = container; }