DataGrid ItemEdit Validation

Hi all,
I have an application with datagrid inline editing
functionality. I have a custom item renderer for all the columns
and i have to perform validations also on the user entered data.
The itemEditEnd function goes like this,
private function editCell(event:DataGridEvent ) : void
if( event.reason == DataGridEventReason.CANCELLED) {
return;
var oldValue:String =
event.currentTarget.editedItemRenderer.data[event.dataField];
var newValue:String =
TextInput(event.currentTarget.itemEditorInstance).text;
if(newValue == "") {
event.preventDefault();
TextInput(dg.itemEditorInstance).errorString ="Enter a valid
string.";
return;
typical ex from Adobe.
It works fine and shows the error string in the exact edited
text box inside Grid.
But Once i integrate wit the DB with DMS call and tried to
edit, the error message is shown at a random place, say on top of
the page.
please help me out to solve this.
thanks in advance

Worst forums ever! Nobody can help with the insertion of a
currencyvalidator in a datagrid itemeditor?

Similar Messages

  • Editing with a DataGrid and validating user input

    Editing
    with a DataGrid Tutorial
    How to edit the information in a Flex 2 DataGrid directly,
    without data binding TextInputs to it.
    Uses a Remote Object, a CFC, and a Microsoft Access database
    to demonstrate how.
    Uses Actionscript to validate the data the user types into
    the DataGrid.

    We created an itemEditor for our dataColumn that was a
    mx:TextInput. Then we used the textInput event to capture keys as
    they are typed. You get a TextEvent from that which you can cancel
    if it something you don't want the user entering. We used regexs
    for are validation here. I'm not sure if this is the best way to
    handle this sort of thing, but it worked.

  • DataGrid and Validation?

    I'm having a hard time putting a CurrencyValidator inside of
    a DataGrid. The breakpoints would indicate that the data binds
    properly, but I get an unfortunately XML mess with big scrollbars
    in the datagrid instead of what I'd expect.
    Here's the GenericDollarFormatItemRenderer.mxml that
    intuition built:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:HBox xmlns:mx="
    http://www.adobe.com/2006/mxml">
    <mx:Script>
    <![CDATA[
    import mx.controls.dataGridClasses.DataGridColumn;
    public var dataField:String;
    [Bindable]
    private var dataString:String;
    public function newInstance():*
    return new GenericDollarFormatItemRenderer();
    override public function set data(value:Object):void {
    if( value != null ){
    super.data = value;
    if( !(value is DataGridColumn) && dataField != null
    && value[dataField] != null ){
    dataString = value[dataField];
    obj:Object;
    ]]>
    </mx:Script>
    <mx:CurrencyValidator id="pnV" source="{ti}"
    property="text"
    trigger="{ti}" triggerEvent="change" required="true" />
    <mx:TextInput id="ti" text="{dataString}"
    updateComplete="dataString=ti.text;"
    change="dataString=ti.text;"/>
    </mx:HBox>
    I'm adding it to my DataGrid as follows:
    [Bindable] private var cf1:ClassFactory = new ClassFactory(
    GenericDollarFormatItemRenderer );
    cf1.properties = { dataField: 'price' };
    <mx:DataGridColumn headerText="price" textAlign="right"
    editable="true" itemRenderer="{cf1}" />
    The data source for the data grid is e4x XML drawn from an
    HTTPService.
    Any experts out there can elucidate this one? If I'm on the
    completely wrong track, let me know! This is a needed to be done
    yesterday type of thing :)
    Thanks
    Alex

    Worst forums ever! Nobody can help with the insertion of a
    currencyvalidator in a datagrid itemeditor?

  • How to validate a whole column of DataGrid

    I want to validate a whole column of DataGrid using
    Validator.
    How to do that?

    Thanks. It works! Prima!
    It's a little bit difficult for me to write and understand the English terms correctly, cause I am German.
    I did not recognize, that I had to go to the Library Module!
    Here I repeat Rikk's way in German:
    Im Bibliothek-Modul
    Rasteransicht
    Bilder selektieren
    Im Menufeld Ad-hoc Entwicklung:
    Freistellungsfaktor einstellen: 16:9

  • Adobe "Best Practices" aren't practical to implement!

    Maybe I'm just venting, but seriously -- what the heck guys
    (Adobe)?
    I've been pretty forgiving in general about this kind of
    stuff but the list of annoying issues I've been finding is getting
    a little long. It seems like every time I make a serious effort to
    implement Adobe's "best practices" form validation functionality,
    it takes a massive amount of time unless you're doing it EXACTLY
    like the example presented here:
    http://www.adobe.com/devnet/flex/quickstart/validating_data/#section3
    And even here, there's *alot* of repetitive (and
    bug-vulnerable) code going on here if you're doing multiple forms,
    or forms of any modest level complexity. God help you if you're
    trying to use these "best practices" using an editable DataGrid
    with validation assistance in a popup window...
    Is this an outdated article or something? Are there any
    useful examples of how to do this more effectively (maybe with some
    code reuse?), that include less commonly (but still important)
    features required for accessibilty (disabling buttons seems to
    screw with tab navigation) or various types of custom
    functionality?
    I know this is like complaining that the air conditioning in
    my private jet is hard to control, but if Adobe's gonna recommend
    doing this, it shouldn't take hours to do, right?

    This may be a good starting to to work on a better solution.
    Seems to take care of the problem of repetitive code at least.
    http://blog.wheelerstreet.com/?p=123
    Hopefully someone from Adobe will address these issues, and
    improve on their documentation and examples. I find myself going
    through the Flex SDK source code sometimes trying to figure out why
    something doesn't work (DataGrid stuff in particular) or how to get
    a certain behavior.

  • Validation on a Datagrid Column

    Hi,
    I have a Datagrid with three columns, out of which two columns are editable. I want to apply string validator on one of the editable column. How can I do this?

    You can have a custom ItemRenderer for that column which has a Validator built in. This has been covered in the docs. See this: http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Live Docs_Book_Parts&file=celleditor_073_17.html

  • Validation on ItemEditEnd of Datagrid

    I have done validations on ItemEditEnd of datagrid but on
    focusout its showinf two alerts. Can anyone specify the
    reason?

    Can we see some simplified code?

  • Date Validation on Datagrid

    Hey guys i have a web app that basically has a browse button  and when the user clicks  the button it prompts for a file on their PC and loads a datagrid.
    My question is rather simple. How do I validate the date columns on datagrid so that it should be formatted like so 17-MAR-10 and not anything other then that. i have a done validation on datagrid with custom classes i built but i have no idea how to go about validating an specific formatt.
    Any Help would be greatly appreciated.
    Thanks
    Miguel

    two assumptions:
    if you need to show the date in your format - then use itemrenderer or labelfunction.
    if you need to show only the rows with that format, then filter the arraycollection - the data provider.

  • Validating in a DataGrid

    I use a TextInput ItemEditor in a Datagrid. How do I make
    sure the user only inputs numeric input? I can use restrict to get
    only integers, but what if I want real numbers with two decimal
    places?

    A simple solution would be to use a Number Validator as seen
    here:
    http://livedocs.adobe.com/flex/3/html/help.html?content=validators_1.html
    :S

  • Simple DataGrid validation Problem

    hi friends
                   I am working on a application in which i  m facing a problem.i have a datagrid having two column field one is simple datagrid column and in other  datagrid column i render textinput as a component. there are only two row in my datagrid.so now i have to apply validation on that data grid.i mean if any textinput componet which is render in second column in data grid left blank and i click on save button then there should be validation Alert messg.
    i am facing a problem on gettin id(instance) of that two rendered textinput component.Please help me out.
    Thanks and Regards
       Vineet Osho

    Hi Vineet Osho,
    You can try this...
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
        >
        <mx:Script>
            <![CDATA[
             import mx.utils.StringUtil;
             import mx.collections.ArrayCollection;
                import mx.controls.TextInput;
                import mx.events.DataGridEvent;
                import mx.controls.Alert;
                public var arr:Array = [];
                public  var incrementer:int;
                private function validateTextInputs():void
                 var strIndexes:String="";
                 var gridDP:ArrayCollection = dataGrid.dataProvider as ArrayCollection;
                 for(var i:int=0;i<gridDP.length;i++)
                  if(StringUtil.trim(gridDP.getItemAt(i).displayText) == "")
                   strIndexes += (i + 1) + ",";
                 if(strIndexes.length > 0)
                  strIndexes = strIndexes.substring(0,strIndexes.length-1);
                  Alert.show("The TextInputs " + strIndexes + " are empty.");
            ]]>
        </mx:Script>
        <mx:DataGrid id="dataGrid" horizontalCenter="0" verticalCenter="0" width="400" height="200">
            <mx:columns>
                <mx:DataGridColumn headerText="First" width="60" dataField="artist" editable="false"/>
                 <mx:DataGridColumn   width = "60" headerText = "Premium %(e.g. Percentage as 100)" >
                       <mx:itemRenderer>
                            <mx:Component>
                                 <mx:TextInput styleName="TextInputRight" focusOut="data.displayText=this.text;" width="100" text="{data.displayText}">
                                 </mx:TextInput>
                            </mx:Component>
                        </mx:itemRenderer>
                  </mx:DataGridColumn>
           </mx:columns> 
                  <mx:dataProvider>
                    <mx:ArrayCollection>
                      <mx:Array>
                        <mx:Object title="Stairway to Heaven" artist="Led Zepplin" displayText=""/>
                        <mx:Object title="How to Save a Life" artist="Fray" displayText=""/>
                      </mx:Array>
                    </mx:ArrayCollection>
                  </mx:dataProvider>
          </mx:DataGrid> 
          <mx:Button id="btn" label="click"  x="527" y="450" click="validateTextInputs()" />
    </mx:Application>
    Thanks,
    Bhasker

  • Validation of user inputs when using ItemRenderers in DataGrid

    Hi,
    I have to show multiple editable columns in a DataGrid.
    The columns may have different formats and datatypes e.g.
    numbers, dates, string etc.
    So I am using TextInput/DateField as a ItemRenderer inside
    the DataGrid. I have also set the rendererIsEditor="true".
    Now I want to apply validation to all these editable columns
    depending on their datatypes.
    I know I can do that by applying validators individually on
    each column.
    But is there a way I can use common validation for all the
    columns that have a similar datatype or that have the same
    renderer?

    You can use the itemEditEnd Event of the DataGrid for your
    validation. Then you can use Actionscript to make sure what the
    user enters is in the right format. Example:
    <mx:Script>
    <![CDATA[
    import mx.events.DataGridEvent;
    public function processEdit(event:DataGridEvent):void {
    cellValue =
    TextInput(event.currentTarget.itemEditorInstance).text; // the
    entered text
    cell = event.dataField; //the datafield attribute of the
    column
    // Determine if the new value is too long for nvarchar field
    if(cell == 'WLNET' && cellValue.length > 35) {
    cellValue = cellValue.substr(0,35); //shortening it for user
    demonstrates expected length
    TextInput(event.currentTarget.itemEditorInstance).text =
    cellValue;
    event.preventDefault(); // Prevent the user from removing
    focus, and leave the cell editor open.
    // Write a message to the errorString property.
    // This message appears when the user mouses over the
    editor.
    TextInput(event.currentTarget.itemEditorInstance).errorString="Entered
    text too long.";
    return;
    ]]>
    </mx:Script>
    <mx:DataGrid id="enrolled_dg" editable="true"
    itemEditEnd="processEdit(event);">
    I learned part of this from the Flex documentation online:
    Determining
    the reason for an itemEditEnd event

  • Validating user input in a datagrid column

    Hi ,
    I have 2 datagrid columns for users to enter data. I want to
    restrict them only to enter numbers. I tried NumberValidator , that
    does not work. Please help !! I am a newbee..
    Thanks in advance..

    We created an itemEditor for our dataColumn that was a
    mx:TextInput. Then we used the textInput event to capture keys as
    they are typed. You get a TextEvent from that which you can cancel
    if it something you don't want the user entering. We used regexs
    for are validation here. I'm not sure if this is the best way to
    handle this sort of thing, but it worked.

  • Validation in datagrid column

    Hi,
    Is there any way to validate datagrid column or cell.
    Please help
    Thanks
    Kumar

    quote:
    Originally posted by:
    peterent
    Follow Tracy's advice, but also handle the itemEditEnd event.
    In that event handler you can find if the data passed validation.
    If it fails you can cancel the edit.
    Look up itemEditEnd in the Flex 2 docs.

  • LabelFunction for cell datagrid validation

      private function price(item:Object, column:DataGridColumn):String {
                 if (item.col1.length !=9) { return item.col1 + "error" };
                 if (item.col2.length > 15){ return item.col2 + "error"};
                 if (item.col2.length > 10){ return item.col3 ,setStyle("color", 0xff0000) + "error" };
    can someone please help me out with this function im trying to validate the items on a datagrid for lenght of theirs string but when i try to do it this way i get really bad errors.
      <mx:DataGridColumn headerText="Vendor Number" dataField="col1" itemRenderer="PriceLabel" />
        <mx:DataGridColumn headerText="Invoice Number" dataField="col2" itemRenderer="PriceLabel"/>
        <mx:DataGridColumn headerText="Invoice Date" dataField="col3" />
    i like to validate each column separetely but its seems to try to do it all at once.
    Any help would be greatly appreciated.
    Thanks
    you

    Try using else if for the last two if statements.
    But you should probably check the column first, then do the formatting, using the column parameter.
    I'll  show you how if you don't know.

  • When clicking on datagrid row it throws me exception - WPF C#

    Whenever I try to double click my datagrid row to edit it, I throws me a few exceptions which doesn't say anything to me. Hovever if
    I set the whole datagrid to IsReadOnly to true, I want have the problem, but I need the second and third columns editable.
    XAML
    <DataGrid x:Name="clientList" HorizontalAlignment="Left" Height="225" Margin="11,126,0,0" VerticalAlignment="Top" Width="349" IsSynchronizedWithCurrentItem="False" AutoGenerateColumns="False" HorizontalGridLinesBrush="#FFB9B9B9" VerticalGridLinesBrush="#FF8B8B8B" GridLinesVisibility="Horizontal" CellStyle="{StaticResource Body_Content_DataGrid_Centering}">
    <DataGrid.Resources>
    <LinearGradientBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" StartPoint="0,0" EndPoint="0,1" >
    <GradientStop Color="#66240000" Offset="0"/>
    <GradientStop Color="#CC240000" Offset="0.65"/>
    </LinearGradientBrush>
    </DataGrid.Resources>
    <DataGrid.Columns>
    <DataGridTextColumn Width="30" Header="Id" IsReadOnly="True" Binding="{Binding Id}"/>
    <DataGridTextColumn Width="100" Header="Company" IsReadOnly="False" Binding="{Binding Company}"/>
    <DataGridTextColumn Width="130" Header="Name, Surname" IsReadOnly="False" Binding="{Binding Name}"/>
    <DataGridTemplateColumn Header="Actions" CellTemplate="{StaticResource myTemplate}"/>
    </DataGrid.Columns>
    </DataGrid>
    C#
    clientList.Items.Add(new DataClients { Id = 1, Company = "My Company", Name = "Jane Roe"});
    Exceptions
    Exception:Thrown: "'EditItem' is not allowed for this view."(System.InvalidOperationException)
    Exception:Thrown: "The string was not recognized as a valid DateTime. There is an unknown word starting at index 0." (System.FormatException)

    You need to set the ItemsSource property of the clientList DataGrid to a collection of DataClients objects that supports editing. HashSet<DataClients> does not for example but List<DataClients> and ObservableCollection<DataClients> does.
    You could call the ToList() method on the collection that you set as the ItemsSource for the DataGrid to convert it to a List<DataClients>:
    clientList.ItemsSource = yourCollection.ToList();
    The "The string was not recognized as a valid DateTime" error message should be pretty self-explanatory. You are trying to convert a string which doesn't contain a valid date or time value to a DateTime value somewhere, perhaps in the 'myTemplate'.
    There is nothing in the DataClients class that you have posted that will cause this exception to be thrown so it is impossible for anyone to tell.
    But please only ask one question per thread and then start a new thread if you have a new question.
    Please also remember to mark helpful posts as answer to close your threads.

Maybe you are looking for

  • Programs hang after 10.3.9 how do i go back?

    i updated to 10.3.9 from 10.3.5 and now quicktime, reason, itunes and probly others wont open at all...i repaired perms and restarted i dont know what else to do. with the software update i installed the quicktime so it should be the corresponding ve

  • Naming components created in a loop?

    I asked this once before, but none of the answers work in this case. I am creating a series of components as children of a viewstack based on XML loaded.  I am looping through the XML and instancing a component for each node. private function createS

  • How to clear two dimension array and content in JTextArea

    hi all.... i have a problem to clear the counter in JTextArea..currently i design a program to store all the student details in two dimensian array...when i click "RESET"button..it will only reset the textarea..but can not clear the actual content in

  • Dynamic variables name

    Hello, I'm a beginner and i'm looking from several days to resolve this problem but i don't find the solution. Can someone help me, Please. for each (var art:XML in Rs) { var eRef:String = String(art.ref); // Exemple Ref AX51 Ref.data = eRef; // Exem

  • Calling WebDynpros in ECC 6 not from the local portal

    Hey, we are having a portal in place pointing to another system with ERP2004 end self developed WebDynpro applications in HCM. Now we want to switch to ECC 6 and so we need to have a local portal in this system - correct? Would we be able to use the