private void DataGrid_GridTapped(object sender, GridTappedEventArgs e) { selectedRowIndex = e.RowColumnIndex.RowIndex; var rowData = dataGrid.GetRecordAtRowIndex(selectedRowIndex); walletSelected = dataGrid.GetCellValue(rowData, "WalletName").ToString(); }
private void findButton_Click(object sender, RoutedEventArgs e) { int result = -1; var task = InputTextDialogAsync(); var task2 = task.ContinueWith(t => { try { result = StudentList.FindItem(int.Parse(t.Result)); } catch (FormatException fe) { NotFindItemAsync(); return; } }); var awaiter = task2.GetAwaiter(); awaiter.OnCompleted(() => { if (result == -1) { NotFindItemAsync(); return; } var record = dataGrid.GetRecordAtRowIndex(result + 1); dataGrid.SelectedItem = record; dataGrid.ScrollInView(new Syncfusion.UI.Xaml.ScrollAxis.RowColumnIndex(result + 1, 3)); }); }
private void Button_Clicked(object sender, EventArgs e) { dataGrid.SelectedItems.Clear(); foreach (elemDescription item in selectedItems) { result += ", " + item.ElemDescription; } ; if (result.Length != 0) { result = result.Substring(2); } dataGrid.View.GetPropertyAccessProvider().SetValue(dataGrid.GetRecordAtRowIndex(rowindex), dataGrid.Columns[columnindex].MappingName, result); dataGrid.View.Refresh(); PopupNavigation.Instance.PopAsync(); }
/** * The grid insertion or adding, we need to move between two states: * When it gets the event add new row, * we get the new row event and move the grid operation to insert, * later when we are in a validation row, we validate the row and that's it. */ private static void CurrentDataGrid_RowValidated(object sender, RowValidatedEventArgs e) { SfDataGrid dataGrid = sender as SfDataGrid; DependencyObject dependencyObject = sender as DependencyObject; var command = dataGrid?.GetValue(ItemChangedCommandProperty) as ICommand; List <object> value = new List <object>(); if ((command != null) && (dataGrid != null)) { var dataValue = dataGrid.GetRecordAtRowIndex(e.RowIndex); var rowState = GetGridOperation(dependencyObject); if (dataValue != null) { BaseDto dto = dataValue as BaseDto; if (dto != null) { dto.LastModification = DateTime.Now.ToLongTimeString(); dto.IsNew = (rowState == GridOp.Insert) ? true : false; dto.IsDirty = true; } } var collection = dataGrid.View.SourceCollection; if (collection is IEnumerable <BaseDto> dtoArray) { if (dtoArray.Count() == 0) { return; } } foreach (var c in collection) { BaseDto v = c as BaseDto; if (v != null) { if (v.IsNew) { value.Add(c); } else if (v.IsDirty) { value.Add(c); } else if (v.IsDeleted) { value.Add(c); } } } IDictionary <string, object> objectName = new Dictionary <string, object>(); value.Add(dataValue); objectName["DataObject"] = GetDataSource(dataGrid); objectName["DataSourcePath"] = GetDataSourcePath(dataGrid); objectName["ChangedValue"] = value; objectName["PreviousValue"] = _lastChangedRow; objectName["Operation"] = rowState; objectName["DeletedItems"] = false; objectName["LastRowId"] = dataGrid.GetLastRowIndex(); _lastChangedRow = dataGrid.GetRecordAtRowIndex(e.RowIndex); command.Execute(objectName); SwitchToUpdate(dependencyObject, rowState); } }
private void ShowTransactionDetailDialog() { ObservableCollection <TransactionDisplayData> data = new ObservableCollection <TransactionDisplayData>(); string currency = ""; string transSizeUnit = ""; string cellValue; foreach (var column in dataGrid.Columns) { if ((column.MappingName == "StatusIcon") || (column.MappingName == "LabelStatusIcon")) { continue; } var rowData = dataGrid.GetRecordAtRowIndex(selectedRowIndex); if (column.MappingName == "Currency") { currency = dataGrid.GetCellValue(rowData, column.MappingName).ToString(); continue; } if (column.MappingName == "TransactionSizeUnit") { transSizeUnit = dataGrid.GetCellValue(rowData, column.MappingName).ToString(); continue; } cellValue = dataGrid.GetCellValue(rowData, column.MappingName).ToString(); if ((column.MappingName == "Debit") || (column.MappingName == "TransactionFee") || (column.MappingName == "Amount")) { cellValue += " " + currency; } else if (column.MappingName == "TransactionSize") { cellValue += " " + transSizeUnit; } data.Add(new TransactionDisplayData(column.MappingName, cellValue)); } SfDataGrid grid = new SfDataGrid(Context) { RowHeight = 30, HeaderRowHeight = 0, GridStyle = new SyncFusionUtilities.CustomGridStyle(), AutoGenerateColumns = false, ColumnSizer = ColumnSizer.None, FrozenColumnsCount = 1, ItemsSource = data }; grid.Columns.Add(SyncFusionUtilities.DataGridUtilities.CreateTextColumn("ColumnOneData", "One", "", 125)); grid.Columns.Add(SyncFusionUtilities.DataGridUtilities.CreateTextColumn("ColumnTwoData", "Two", "", 500)); var builder = new Android.Support.V7.App.AlertDialog.Builder(Context); builder.SetTitle("Transaction Details"); LayoutInflater layoutInflater = Activity.LayoutInflater; View dialogView = layoutInflater.Inflate(Resource.Layout.customdialoglayout, null); LinearLayout lay = dialogView.FindViewById <LinearLayout>(Resource.Id.customLinearLayout); lay.AddView(grid); builder.SetView(dialogView); builder.SetNegativeButton(Android.Resource.String.Ok, (senderAlert, args) => { }); builder.Show(); }