How to add a 2-column combobox to XtraGrid - xtragrid

How can add a 2-column combobox to Xtragrid which has one col is stored to database and the other is used to display in the xtragrid.
Thank so much

You need to create a RepositoryItemLookUpEdit then set it as your column.ColumnEdit property:
//Set the dropdown values for the cell
RepositoryItemLookUpEdit colCombo = new RepositoryItemLookUpEdit();
colCombo.ShowHeader = true;
colCombo.ShowFooter = false;
colCombo.DataSource = dsRules.YOURTABLE;
colCombo.DisplayMember = "DESCRIPTION";
colCombo.ValueMember = "ID"; //Your DB column
colCombo.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
colCombo.NullText = "";
//colGRIDCOLUMN is your DevExpress.XtraGrid.Columns.GridColumn
colGRIDCOLUMN.ColumnEdit = colCombo;
LookUpColumnInfoCollection coll = colCombo.Columns;
coll.Add(new LookUpColumnInfo("DESCRIPTION", "DESCRIPTION", 0));
coll.Add(new LookUpColumnInfo("ID", "ID", 0));
colCombo.BestFit();

Related

Dynamic report columns in BIRT

I have a BIRT report, which simply selects all the columns of a table. Every time a new column is added to the table I have to modify the report to visualize the new column. Is it possible somehow to show the result of a "select * from table" query in the report, so I shouldn't modify the report template anymore? The order of columns is not important.
Thank You.
This is not directly possible.
However, using the DE API, you can create and save a new rptdesign file based on the query, then in a second step execute that report.
The example at https://www.eclipse.org/birt/documentation/integrating/deapi.php only shows how to create layout items, but you can as well create Data Sources and Data Sets.
This is a bit tricky however, so unless you need this quite often, it is not worth the effort.
Here is an excerpt from a script I am using in a file sql2rptdesign.rptdesign to create a new report design. This should give you an idea:
importPackage(Packages.org.eclipse.birt.data.engine.api);
importPackage(Packages.org.eclipse.birt.data.engine.core);
importPackage(Packages.org.eclipse.birt.report.model.api);
importPackage(Packages.org.eclipse.birt.report.model.api.elements.structures);
importPackage(Packages.org.eclipse.birt.report.model.api.util);
importPackage(Packages.org.eclipse.birt.data.engine.api.querydefn);
var engine = reportContext.getReportRunnable().getReportEngine();
var myconfig = reportContext.getReportRunnable().getReportEngine().getConfig();
var designFactory = designHandle.getElementFactory();
// Ein neues DataSet anlegen
var de = DataEngine.newDataEngine( myconfig, null );
var dsrc = reportContext.getDesignHandle().findDataSource("lisa");
var dsHandle = designFactory.newOdaDataSet("Main", "org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" );
dsHandle.setDataSource(dsrc.getName());
dsHandle.setQueryText(sql);
designHandle.getDataSets( ).add( dsHandle );
Then I add the output columns (I parsed the SQL statement beforehand to get the necessary information). I don't know if this is strictly needed.
var numColumns = 0;
for (var position=0; position<rows.length; position++) {
var row = rows[position];
var colName = row[0];
if (colName == "__Template") {
continue;
}
var colTyp = row[1];
var colWidth = row[2];
var resultCol = new OdaResultSetColumn();
resultCol.setColumnName(colName);
resultCol.setNativeName(colName);
resultCol.setDataType(colTyp);
resultCol.setPosition(position+1);
numColumns = position + 1;
dsHandle.getPropertyHandle(DataSetHandle.RESULT_SET_PROP).addItem(resultCol);
var resultHint = new ColumnHint();
resultHint.setProperty(ColumnHint.COLUMN_NAME_MEMBER, colName);
dsHandle.getPropertyHandle(DataSetHandle.COLUMN_HINTS_PROP).addItem(resultHint);
}
And then add a table, its column bindings, columns, detail rows and cell contents to the layout. This is a bit lenghty.
// Tabellarisches Layout
var elementFactory = designHandle.getElementFactory();
var body = designHandle.getBody();
var tab = elementFactory.newTableItem("Main", numColumns);
tab.setDataSet(dsHandle);
tab.pageBreakInterval = 9999;
for (var colNum=0; colNum<numColumns; colNum++) {
var r = rows[colNum];
var colName = r[0];
var colNameSlashes = addSlashes(colName);
var colType = r[1];
var width = r[2];
var pattern = r[3];
var align = r[4];
// Binding
var colBinding = StructureFactory.createComputedColumn( );
colBinding.setName(colName);
colBinding.setExpression( 'dataSetRow[' + colNameSlashes + ']');
colBinding.setDataType(colType);
tab.addColumnBinding(colBinding, true);
// Überschrift
var textdata = elementFactory.newTextData(null);
textdata.setContentType("plain");
textdata.setValueExpr(colNameSlashes);
textdata.setStringProperty("whiteSpace", "normal");
tab.getLayoutModel().getCell(1,colNum+1).getContent().add(textdata);
// Wert
var textdata = elementFactory.newTextData(null);
textdata.setContentType("plain");
textdata.setHasExpression(true);
textdata.setStringProperty("whiteSpace", "normal");
var expr = 'row[' + colNameSlashes + ']';
textdata.setValueExpr(expr);
tab.getLayoutModel().getCell(2,colNum+1).getContent().add(textdata);
// Spaltenbreite und Ausrichtung
var columnHandle = tab.getColumns().get(colNum); // 0-basiert?
if (width) {
columnHandle.setProperty("width", StringUtil.parse(width));
}
}
body.add(tab, 0);
And finally save the new file:
designHandle.saveAs(designFilename);
However, this doesn't use a template as you would like to do.

Bind List to GridviewComboboxcolumn in telerik radgrindview (winform)

I have a generic List like
List<return> returnlist
class return
{
public string returnid {get; set;
...
public List<string> Vouchernumbers
}
I bind the returnlist to the telerik radgridview.
How can i bind the voucherlist to the GridviewComboboxcolumn for each row ?
I have bind the voucherlist to the combobox after radgridview_complete_binding.
You need to create the grid with columns and data
You need to add the combobox column, initialize it.. Please check you need to have a dataeditor in here
Assign the string to datasource
comboColumn.DataSource = new String[] { "Test1", "Test2"};
You can bind the collections too:
Binding list BindingList<ComboBoxDataSourceObject> list = new BindingList<ComboBoxDataSourceObject>();
ComboBoxDataSourceObject object1 = new ComboBoxDataSourceObject();
object1.Id = 1;
object1.MyString = "Test 1";
list.Add(object1);
ComboBoxDataSourceObject object2 = new ComboBoxDataSourceObject();
object2.Id = 2;
object2.MyString = "Test 2";
list.Add(object2);
colboCol2.DataSource = list;
radGridView1.Columns.Add(colboCol2);
create radcombobox and set datasource and add it to rad grid
eg :
GridViewComboBoxColumn col = new GridViewComboBoxColumn();
col.DataSource = DAL.ActiveDb.GetList<SalesRep>().ToList().OrderBy(x => x.RepName).Select(x => new { Id = x.Id, x.RepName });
col.DropDownStyle = RadDropDownStyle.DropDown;
col.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
col.DisplayMember = "RepName";
col.ValueMember = "Id";
col.FieldName = "RepId";
col.HeaderText = "Rep Name";
col.Width = 200;
//var t = gridColInfo.Where(x => x.ColumnName.ToLower() == "repid").FirstOrDefault();
//if (t != null)
//{
// col.Width = t.ColumnWidth;
//}
this.radGridBillwiseOpening.Columns.Add(col);

How TChart point series bottom text hide?

I'm use TChart version .Net & VS2005.
The problem of adding a point series.
How TChart point series bottom text hide?
Help me please. Thank you. =)
My Code :
private void GridNotch()
{
Steema.TeeChart.Styles.Points NotchPoint = new Steema.TeeChart.Styles.Points();
TChart1.Series.Add(NotchPoint);
Steema.TeeChart.Axis axis = new Steema.TeeChart.Axis();
TChart1.Axes.Custom.Add(axis);
axis.StartPosition = 5;
axis.EndPosition = 5;
axis.Labels.Items.Add(0, " ");
axis.Labels.Items.Add(5000, " ");
axis.Labels.Items[0].Visible = false;
axis.Labels.Items[1].Visible = false;
axis.Title.Caption = "";
axis.Title.Font.Color = Color.Black;
TChart1.Series[TChart1.Series.Count - 1].CustomVertAxis = axis;
if (dt_Notch.Columns.Count == 0)
{
dt_Notch.Columns.Add("Value", typeof(int));
dt_Notch.Columns.Add("Label", typeof(string));
DataRow row;
row = dt_Notch.NewRow();
row["Value"] = "100";
row["Label"] = "B5";
dt_Notch.Rows.Add(row);
}
TChart1.Series[TChart1.Series.Count - 1].XValues.DataMember = "Value";
TChart1.Series[TChart1.Series.Count - 1].YValues.DataMember = "Value";
TChart1.Series[TChart1.Series.Count - 1].LabelMember = "Label";
TChart1.Series[TChart1.Series.Count - 1].DataSource = dt_Notch;
}
My Graph :
Want Graph :
I see you are assigning the "B5" in your code:
row["Label"] = "B5";
You can either remove that label or force your bottom axis to show values and not labels:
TChart1.Axes.Bottom.Labels.Style = AxisLabelStyle.Value;

Devexpress Gridview Hide Editform in asp.net mvc

If my CustomerName FieldName equals to "MyCustomer" , i want to hide editing for that row.
If customername == "MyCustomer , hide column editing.
How can i hide column editing according to "MyCustomer"?
settings.Columns.Add(s =>
{
s.FieldName = "CustomerName";
s.Caption = "Customer";
s.Name = "CustomerColumn";
s.ColumnType = MVCxGridViewColumnType.ComboBox;
var comboBoxProperties = s.PropertiesEdit as ComboBoxProperties;
comboBoxProperties.DataSource =Model.CustomerList;
comboBoxProperties.TextField = "Customer_Name";
comboBoxProperties.ValueField = "Customer_Id";
comboBoxProperties.ValueType = typeof(int);
comboBoxProperties.ClientInstanceName = "CustomerColumn";
});
Any help will be appreaciated with points.
settings.CommandButtonInitialize = (s, e) => {
if (e.ButtonType == ColumnCommandButtonType.Edit) {
MVCxGridView g = s as MVCxGridView;
var value = (int)g.GetRowValues(e.VisibleIndex, "RowFieldName"); //use a correct field name and cast a resultant value to a correct value type
e.Visible = value > 10; // for example, only
}
};
Fortunately , i have myself.I found a solution.
It works.Hope this helps who has the same problem in the future.

Create a store from Code Behind and filter its content and bind it to Combobox Ext.Net 2.2

I am creating combobox in a component Column in a GridPanel from codebehind. There is requirement to create a store and filter its content according to some condition and bind it to the created combobox. Store is getting bind to combo but filter is not working. Please help me to get the proper solution for this. My code snippet is given below.
List<object> storeDataProductClass= new List<object>();
storeDataProductClass.Add(new { text = "Class0", value = "Class0", productIndex = 0});
storeDataProductClass.Add(new { text = "Class1", value = "Class1", productIndex = 1});
storeDataProductClass.Add(new { text = "Class2", value = "Class2", productIndex = 2});
storeDataProductClass.Add(new { text = "Class3", value = "Class3", productIndex = 3});
storeDataProductClass.Add(new { text = "Class4", value = "Class4", productIndex = 4});
Ext.Net.ComboBox cmbClass = new ComboBox();
cmbClass.ID = "cmbClass_" + i;
Model classModel = new Model();
classModel.Fields.Add(new ModelField("text", ModelFieldType.String));
classModel.Fields.Add(new ModelField("value", ModelFieldType.String));
classModel.Fields.Add(new ModelField("productIndex", ModelFieldType.Int));
Ext.Net.Store storeClass = new Ext.Net.Store();
storeClass.ID = "storeClass_" + i;
storeClass.AutoDataBind = true;
storeClass.Model.Add(classModel);
storeClass.DataSource = storeDataProductClass;
storeClass.DataBind();
storeClass.Filter("productIndex", i.ToString());
cmbClass.Store.Add(storeClass);
cmbClass.DisplayField = "text";
cmbClass.ValueField = "value";
compColumn.Component.Add(cmbClass);

Resources