displaying precision value.... in flex text box - apache-flex

in my flex application im retrieving a data from database.....
(ie) price as decimal(18,4)...
Now i need to display the retrieved value in an flex text box
textbox name is price.text...
obj is object name...
i have used the following in code...it not works...
price.text = obj.Price.toPrecision((18,4));
.kindly give ur suggestions folks....

Take a look at the NumberFormatter. To follow your example, you would declare a NumberFormatter like so:
<mx:NumberFormatter
id="myNumberFormatter"
precision="4"/>
or in Actionscript:
var myNumberFormatter:NumberFormatter = new NumberFormatter;
myNumberFormatter.precision = 4;
Then use the NumberFormatter's format function on your value:
price.text = myNumberFormatter.format(obj.Price);

Related

Telerik Auto Complete textbox bind text and value

I have an auto complete text box . I am able to bind the the data to the text box .
I am able to retrieve the value and store it in the database .
Now I want know how do I bind the the saved value in the database to the auto complete text box again.
I tried somewhat like this
AutoCompleteBoxEntry childNode = new AutoCompleteBoxEntry();
childNode.Text = lblTeamLeaderName.Text;
childNode.Value = lblTASKTEAM_ID.Text;
txtusers.Entries.Add(childNode);
and
txtusers.Entries[0].Value = lblTASKTEAM_ID.Text;
txtusers.Entries[0].Text = lblTeamLeaderName.Text;
But still value which is saved is not being shown in the textbox .
I want to bind the text and value some what like dropdownlist box .
Can anyone tell where I am going wrong ?
txtusers.Entries.Add(new AutoCompleteBoxEntry()
{
Text = lblTeamLeaderName.Text,
Value = lblTASKTEAM_ID.Text
});
Try this

How to exclude unnecessary buttons in ALV toolbar?

So, inside the TOOLBAR event of the CL_GUI_ALV_GRID the parameter E_OBJECT has the table MT_TOOLBAR that I can access to change all the buttons manually.
Is there a better way to include/exclude standard buttons in the toolbar than simply creating them like custom-buttons in the toolbar event?
Similar to REUSE_ALV_GRID_DISPLAY in class CL_GUI_ALV_GRID there is also a way.
Define a table of type UI_FUNCTIONS and a work area of type UI_FUNC :
data: lt_exclude type ui_functions,
ls_exclude type ui_func.
Append the attributes of the functions you want to hide to the table:
ls_exclude = cl_gui_alv_grid=>mc_fc_sum.
append ls_exclude to lt_exclude.
The attributes of the standard functions all begin with the prefix MC_FC_, in addition, there is the prefix MC_MB_ for an entire menu in the toolbar.
Pass the table using method set_table_for_first_display with parameter it_toolbar_excluding
If you use REUSE_ALV_GRID_DISPLAY in your code, this might be helpful for you:
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = 'ZPROGRAM'
i_callback_pf_status_set = 'SET_PF_STATUS'
it_fieldcat = it_fieldcat
tables
t_outtab = gt_itab.
Your SET_PF_STATUS should be like this in order to eliminate some of the buttons you want. In this example I'm eliminating the "SORT_UP" button.
form set_pf_status using rt_extab type slis_t_extab.
data: lv_flag VALUE 'X'.
if lv_flag is not INITIAL.
append '&OUP' to rt_extab.
endif.
set pf-status 'STANDARD' excluding rt_extab.
endform. "set_pf_status
Hope it was helpful.
Talha
class lcl_event_alv definition .
public section .
methods handle_toolbar for event toolbar of cl_gui_alv_grid
importing e_object e_interactive sender.
class lcl_event_alv implementation .
method handle_toolbar.
delete e_object->mt_toolbar where function = '&LOCAL&INSERT_ROW' or function = '&LOCAL&DELETE_ROW'
or function = '&LOCAL&APPEND' or function = '&LOCAL&COPY'
or function = '&LOCAL&PASTE' or function = '&LOCAL&CUT'
or function = '&LOCAL&COPY_ROW' or function = '&LOCAL&CUT'.
endmethod.
data : go_event type ref to lcl_event_alv.
create object go_event .
set handler go_event->handle_toolbar for go_grid1.
call method go_grid1->set_table_for_first_display
exporting
is_layout = gd_layout
is_variant = value disvariant( report = sy-repid handle = 'GO_GRID1' )
i_save = 'A'
changing
it_fieldcatalog = gt_fcat1
it_outtab = gt_items1.

Data formatting in GridView with AutoGenerateColumns true

I've got a GridView in ASP.NET 2.0 with AutoGenerateColumns set to true. It'll be bound at runtime to a DataSet with one of many possible schemas, and I'd rather not set up grids and columns for each possible schema.
Some of the columns in the grid will sometimes be floating point values. It seems the default number formatting turns 0.345 into 0.345000. Is there a way to change the default number format so it trims to a set number of decimals?
You could use strings in your schema instead of floating point for display purposes, and perform the formatting manually, something like this:
EDIT: Without LINQ, you can do the same thing by modifying rows in the schema:
// load source data
DataSet myData = GetDataSet();
// create column for formatted data.
myData.Tables["MyTable"].Columns.Add("AmountFormatted", typeof(string));
// apply formatting
foreach (DataRow dr in myData.Tables["MyTable"].Rows)
dr["AmountFormatted"] = string.Format("{0:0.###}", dr["Amount"]);
// remove source column and replace with formatted column
myData.Tables["MyTable"].Columns.Remove("Amount");
myData.Tables["MyTable"].Columns["AmountFormatted"].ColumnName = "Amount";
C#, LINQ-Based solution:
var theData = GetDataSchema1();
var dataSource = theData.Tables["MyTable"].Select().Select(dr =>
new { /* select only columns you want displayed, and apply formatting */
MyColumn1 = dr["MyColumn1"],
MyColumn2 = dr["MyColumn2"],
MyColumn3 = String.format("#.###", dr["MyColumn3"]),
MyColumn4 = dr["MyColumn4"],
MyColumn5 = dr["MyColumn5"]
}
);
MyGridView1.DataSource = dataSource;
MyGridView1.DataBind()

How to get multiple value from one textbox?

I have created web application and textbox as a textarea. I am using javascript for validation. When I enter value in text box so it should be number not alphabet I have use textmode is multiple line.
My problem is that how I get multiple value from textbox and store in array in javascript and check each value is number or not. I am using the web form. Please help me.
You can get the value from a textarea like
var txtvalue = document.getElementById("txtareaid").value
and if are using a separator then something like
var txtvaluearray = document.getElementById("txtareaid").value.split(';')
will get you all the values in an array if the seperator is ;
Edit
As per your update you can use \n as the separator and as pointed by #Sohnee you can do the validation.
As addition to rahul:
If you want the values in the textarea seperated by line, you can use \r\n as the splitter.
This is a starter for ten.
var textValues = document.getElementById("mytextarea").value.split("\n");
for (var i = 0; i < textValues.length; i++) {
if (isNaN(textValues[i])) {
alert(textValues[i] + " is not a number.";
}
}

Flex Rich Text Editor - Limiting the number of characters

Is there a way to restrict the number
of characters in the Flex Rich Text Editor?
I guess there should be, since it's possible
in a textarea. So, if I could get hold
of the textarea contained in the rich
text editor, I would be able to do it
I think this would be fairly easy in actionscript, although I'm not exactly sure how one would do it in mxml. It appears that there are two children that are contained in the RichTextEditor, one of them being TextArea. According to the documentation (http://livedocs.adobe.com/flex/3/langref/mx/controls/RichTextEditor.html#propertySummary), you can access the subcontrols like so:
myRTE.toolBar2.setStyle("backgroundColor", 0xCC6633);
With myRTE being the instance of your text editor. So my guess would be something like this would work:
myRTE.textArea.maxChars = 125;
With 125 being the number a characters you would want restricted to.
i just ran into this.
setting your maxChars on the textArea will provide a limit to the text area, but that won't be representative of the number of characters the user can type.
as the user is typing, markup is added behind the scenes, and that greatly increases the char count.
for example, if i type the letter 'a' into a RichTextEditor, i get a char count of 142 and this htmlText:
<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Verdana" SIZE="10" COLOR="#0B333C" LETTERSPACING="0" KERNING="0">a</FONT></P></TEXTFORMAT>
i could not see a straightforward way to get a proper maxChar to work out of the box, so i extended RichTextEditor and gave it a maxChar. if maxChar > 0, i added a listener to "change" and did something like this in the event handler:
protected function handleTextChange(event:Event) : void
{
var htmlCount:int = htmlText.length;
// if we're within limits, ensure we reset
if (htmlCount < maxChars)
{
textArea.maxChars = 0;
this.errorString = null;
}
// otherwise, produce an error string and set the component so the user
// can't keep typing.
else
{
var textCount:int = textArea.text.length;
textArea.maxChars = textCount;
var msg:String = "Maximum character count exceeded. " +
"You are using " + htmlCount + " of " + maxChars + " characters.";
this.errorString = msg;
}
}
the idea is to apply a maxChars to the text area only when in the error state, so the user cannot type anything additional and will be prompted to erase some chars. once we leave the error state, we need to set the textArea.maxChars to zero so they can continue.

Resources