Modify cell content when row created in Rad grid - dynamic

I have a rad grid dynamically created. I have a status column in database. When binding the value to the grid, I want to show a de-activate button when status is 0 and activate button when status is 1. Upon clicking the button, the status should change from active to inactive and vice versa? What should be the column type and how to write an event for the button click?

I have accomplished the same task as shown below :
GridButtonColumn btncol = new GridButtonColumn();
btncol.ButtonType = GridButtonColumnType.LinkButton; // setting ButtonType as LinkButton
btncol.DataTextField = "Active"; // setting DataTextField to first column in DataTable
this.RadGrid1.MasterTableView.Columns.Add(btncol);
Better example is given in following link :
http://www.telerik.com/help/aspnet-ajax/grid-programmatic-creation.html

Related

PowerBuilder Changing button text depending on database column value

In my database I have a column where default_column_value = 1.
I currently have a button that displays the text "Pay Enabled". When clicked, this button toggles the column value between 1 and 0. When the column value is at 1 the button should display "Pay Enabled" When it is at 0 it should display "Pay Disabled". What is the best way to achieve this?
Below is the window where I have programmatically added the button.
btn_add("Pay Enabled", true)
btn_add()
ii_blank_btns += 1
blank_btns[ii_blank_btns].object.t_text.y = 50
blank_btns[ii_blank_btns].object.t_text.text = as_name
blank_btns[ii_blank_btns].object.c_color.expression = '0'
blank_btns[ii_blank_btns].GroupCalc()
blank_btns[ii_blank_btns].visible = true
Properties Image
Use a datawindow button, that is a button defined in the datawindow.
In the properties of that button, click on the 'Expression' icon of the text and put something like if(col_value = 1, 'Payment Enabled', 'Payment Disabled').
See hereunder the 'Expression' button is on the right of the text 'none' and contains the expression above.

How to force load and item by key in form?

The case
1 - I have an accordion widget with datasource Tasks.
2. - I have a form to display info on a selected Task. It has a datasource TaskByKey.
The sought solution:
There is a button on both Tasks AccordionRow.
onClick the button should, based on the Key of the item of the AccordionRow load its data in the form with datasource TaskByKey.
What I tried:
I tried implementing the solution given as an example in Google's template, Project Tracker:
/**
* Navigates user to the specific project view page.
* #param {!string} projectKey - project key to view.
* #param {boolean=} forceReplace - optional flag that forces to replace URL
* state in cases when state push would be normally used.
*/
function gotoViewProjectPageByKey(projectKey, forceReplace) {
var params = {
projectKey: projectKey
};
gotoViewProjectPageByParams(params, forceReplace);
}
Of course the above example targets a page, where as I want to change the datasource of an element on the same page.
TLDR
How can I set the onClick event of a button to load an item by key from datasource_X to datasource_X_byKey?
Considering the fact that your TaskByKey pretends to filter only a specific task... you can put the following on the onClick event of the button.
var taskKey = widget.datasource.item._key;
var ds = app.datasources.TaskByKey;
ds.query.filters._key._equals = taskKey;
ds.load();
//Then, here you either navigate to a page or open a dialog or open a popup.
The above will work considering that your Tasks datasource and your TaskByKey datasource come from the same model.
Reference: https://developers.google.com/appmaker/scripting/api/client#Query

Modifying column header names in Master-Detail grid in Devexpress

I have a Master-Detail set up with 2 grids. On the master grid, I have the ShowOnlyPredefinedDetails option set to false.
This means that I see a little + sign that allows me to expand the details of the detail grid (in the master grid). I would like to rename
some columns in that section as well as hide certain columns. I'm using VB.NET How do I go about this. See image.
You can accomplish this by using the grid control ViewRegistered event, from there you can modify the columns in that grid view that have columns within them that you want to modify, rename, or remove. Here is an example, I hope that it helps:
private void myGridControl_ViewRegistered(object sender, DevExpress.XtraGrid.ViewOperationEventArgs e)
{
if (e != null)
{
if (e.View != null)
{
//Inside of this statement you can adjust, add, and modify all of the columns inside of that grid that appears when you click on the +
(e.View as GridView).Columns["myHiddenColumn"].Visible = false;
(e.View as GridView).Columns.Add(new GridColumn() { Name = "AddColumn", Caption = "Name To Display", Visible = true, FieldName = "DataField"});
(e.View as GridView).Columns["DataField"].OptionsColumn.AllowEdit = false;
(e.View as GridView).Columns["DataField"].OptionsColumn.AllowFocus = false;
(e.View as GridView).Columns["DataField"].OptionsColumn.ReadOnly = true;
}
}
}
I think all you need to do is create a second grid view for your details. If you haven't already done this, do the following:
In your grid designer, click "Retrieve Details" if you have not already done so. This will cause the designer to recognize that you have a second level in your bound object:
Once you see the second layer, now you need a new grid view for it. Click on "Click here to change view" and select "Create a new view" and pick "GridView."
Now you will see both grid views from the designer, and clicking on one or the other will change the context of the menus to the left:
For example, if you have gridView2 selected, when you click on the "Layout" menu, it will show the current layout for your detail grid rather than the master grid. From here, you can remove or add columns as you see fit. Likewise, from the "Columns" menu you will see the new columns (you may have to add them to the view by dragging them over), and you can change the Caption property to change the text of the title.
I suggest you use the Data Annotation attributes with properties of your data-classes to declare how you data should be displayed in GridControl:
To skip column generation for the specific property you can mark this property with the <DisplayAttribute(AutoGenerateField := false)> declaration.
To prevent column from displaying you can mark this property with the <DisplayAttribute(Order := -1)> declaration. Later, user can show this column via Column Chooser UI.
To specify the column caption use the <DisplayAttribute(Name := "YOUR CAPTION")> declaration.
You can also control filtering/editing/formatting and validation capabilities.
Related Links:
Tutorial: Create and Manage Data in Code and Apply Data Annotation Attributes
Video Tutorial: Create and Manage Data in Code and Apply Data Annotation Attributes

Accessing Data From Dynamically Generated TextFields

I'm currently working on functionality that would allow the user to add a set of checkboxes, textfields, and buttons on demand. Afterward, I would like to be able to access the text stored in the textfield as well as the state of the checkbox.
My current code is as follows:
#FXML VBox box = new VBox(10);
{
HBox horizBox = new HBox(10);
Button button3 = new Button("Hi");
TextField textTest = new TextField();
CheckBox check3 = new CheckBox();
box.getChildren().addAll(horizBox);
horizBox.getChildren().addAll(textTest, check3, button3);
System.out.println(textTest.getText());
}
Even after giving a variety of inputs, the output is still blank. How do I access the data in a dynamically generated textbox? For example, if I wanted to get the input from the fourth textbox that the user made, how would I go about doing that?
Thanks.

flex edit menu operations on multiple textareas

I have a grid in which one column is having itemrenderer as textarea. My application is menu controled. Now I want to perform edit operations on the textarea using menu items.
Like if I select some text from a textarea in the grid, then I select a menu item "Cut" then it should cut the selected text from the textarea. In this manner I would lie to perform all operations.
I am not getting how to get that the operation is to be performed on which textarea?
inside your menu item click handler, try:
var fcs:IFocusManagerComponent = focusManager.getFocus();
if(fcs is TextArea)
{
var txt:String = TextArea(fcs).text;
System.setClipboard(txt);
}