How Auto Fit column in DataGrid

Is it possible to set autofit in DataGrid column ?
Without auto fit the users must resize the table every
time.

Please Check this example
http://www.flex4ex.com/?p=24

Similar Messages

  • How to auto fit column width?

    Hi experts,
      When I design a input schedule, I find a problem, some columns can auto fit column width when I input numerics, some columns can not! how can I fix my input schedule and let all column can auto fit column width?
    best regard
    Evans.

    Evans,
          If you are using standard template and which is not working for 2 data ranges.
          I think you can customize using VBA Macros. It is possible using Macros. I'm not sure is it BUG from SAP.
         Try to put VBA code in AFTER_REFRESH i guess.
          You can VBA Macro code mention below.
          for Column D: Columns("D:D").EntireColumn.AutoFit
          For all Columns: Cells.EntireColumn.AutoFit
          For Only Data Ranges: Determine columns from data range using VBA code and use VBA code given for Column .
    Thanks,
    Ben.

  • Auto fit columns in excel using open xml

    I have generate excel using open xml and it contain auto fit property for columns. my problem is that the excel is opening very well in kingsoft spreadsheets
    and other tools, but not opening in microsoft excel 2013 and older version. Is there any solution for auto fit columns in excel using open xml and should open in Microsoft excel  all version

    Hi Raj12345,
    >> I have generate excel using open xml and it contain auto fit property for columns. my problem is that the excel is opening very well in kingsoft spreadsheets and other tools, but not opening in microsoft excel 2013 and older version
    I assume you was using OpenXML SDK and I'm afraid we are not able to find the root cause according to your description, would you mind sharing us some code sample to reproduce this issue.
    >> Is there any solution for auto fit columns in excel using open xml and should open in Microsoft excel  all version
    As far as I know, there is no auto fit property for columns in excel with openxml. I am afraid that you need to calculate the column width depending on the cell contents, and then set the column width. The link below shows more details:
    # Solution: How to AutoFit Excel Content
    https://social.msdn.microsoft.com/Forums/office/en-US/28aae308-55cb-479f-9b58-d1797ed46a73/solution-how-to-autofit-excel-content?forum=oxmlsdk
    Best Regards,
    Edward
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

  • Auto fit column width for subtotals

    Hello,
    We created subtotals using member sorting & grouping in EPM report. some reason Auto fit column width is not working for sub totals.
    Any idea or any one encounter similar issue?
    Thanks,
    Srinivas Thota

    Hi Raju,
    I checked notes but i dont see any details in SP16 patch 01 documentation.
    The note 1683111 related to SP07.
    Thanks,
    Srinivas Thota

  • How to hide column of DataGrid

    I am making a web part in which I am using System.Web.UI.WebControls.DataGrid control.
    It's AutoGenerateColumns property is set to TRUE.
    I am trying to hide a column at run time. I have written the following code on this controls ItemCreated event but it only works if I e.Item.Cells[0] and it doesn't work for any other value for e.g. e.Item.Cells[1] and e.Item.Cells[6].
    There are 9 columns in my DataGrid control.
    Code
    protected void grd1_ItemCreated(object sender, DataGridItemEventArgs e)
    { e.Item.Cells[0].Visible = false; //works fine
    e.Item.Cells[1].Visible = false; //gives error e.Item.Cells[2].Visible = false; //gives error
    Error
    Specified argument was out of the range of valid values.
    Parameter name: index
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    How to hide a particular column?

    Hi Frank,
    You can try something similar to the below in 'RowCreated' event Instead
    protected void gridView_RowCreated(object sender, GridViewRowEventArgs e)
    e.Row.Cells[1].visible =false;
    OR I would say hiding column is not something that is to be done at row level, so you can hide columns outside any of the grid view event after binding.
    e.g.
    gridview1.columns[1].visible=false;
    I am using DataGrid control in which there is no RowCreated event.
    I have tried second approach but it also doesn't work.

  • How create grouped column in DataGrid ?

    Hi all,
         I can create grouped column in AdvancedDataGrid. So in DataGrid, how I create grouped column ?
    Thanks.

    I have a problem that no anyone can help me to now. Sometime, I think that it's bug of ADG.
    My goal same as from http://blogs.adobe.com/aharui/BlinkWhenChanged/dg.swf . But if I use ADG and with a scroll ! And when scroll up or down background color change not right.
    It's a big problem ! Yep, when I use ADG, I can create group columns but ADG, I can't !
    Is there any ways for me?

  • 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

  • NW04s: How to change column settings like 'do not adjust' 'fit to resuts' e

    In the new Analyzer, old report format: how to change column settings: do not adjust, fit to results, etc.?
    Regards
    -Bala

    Hello,
    In the properties dialog of the Grid and some other items, there is a checkbox by name "Autofit". When this is checked, the result columns are expanded to correct data widths.
    Regards,
    Manjunath

  • How to add Column to Adobe flex mx:DataGrid in mxml and/or actionsctpt?

    I have simple mxml code
    <mx:DataGrid id="DGG"
                 editable="true">
        <mx:dataProvider>
            <mx:Object scheduledDate="4/1/2006"/>
        </mx:dataProvider>
    </mx:DataGrid>
    <mx:Button id="SetBut"
               label="Set Array as Data Provider"
               click="SetDP(); AddBut.visible = true;"
               x="100.5"
               y="164"
               width="211"/>
    <mx:Button id="AddBut"
               label="Add a column!"
               click="AddCol();"
               x="100.5"
               y="194"
               width="211"
               visible="false"/>
    <mx:Script>
        <![CDATA[
            import mx.controls.dataGridClasses.DataGridColumn;
            import mx.collections.ArrayCollection;
            [Bindable]
            public var MyAC:ArrayCollection=new ArrayCollection([{scheduledDate: "4/1/2006", homeTeam: "Chester Bucks"}]);
            public function SetDP():void
                DGG.dataProvider=MyAC
            public function AddCol():void
                MyAC.addItem({scheduledDate: "4/5/2007", homeTeam: "Long Valley Hitters", Umpire: "Amanda Hugenkis"});
                DGG.columns.push(new DataGridColumn("Umpire"));
        ]]>
    </mx:Script>
    I want to add rows to my table datagrid how to do such thing?
    How to add Column to Adobe flex mx:DataGrid in mxml and/or actionsctpt?
    (You can put this code in Flash or AIR app - it will compile with no errors, but will not add any columns=( )

    Change this:
                 public function SetDP():void
                    DGG.dataProvider=MyAC
                    MyAC.addItem({scheduledDate: "4/5/2007", homeTeam: "Long Valley Hitters", Umpire: "Amanda Hugenkis"});
                public function AddCol():void
                    var dgc:DataGridColumn = new DataGridColumn("Umpire");
                    var ca:Array = DGG.columns;
                    ca.push(dgc);
                    DGG.columns = ca;
    Dany

  • How to swf auto fit to screen when start

    how to swf auto fit to screen when start without any menu bar or window screen, i had use adobe flash player convert swf to ex, will fit to screen works in exe format?

    Dear Josephine,
       There is no option the way you want of autofit. Rather while opening the CSV in excel u can do the required formatting.
    Regards,
    Deva.

  • How to make a unbound datagrid (wpf) with custom columns

    I need to create a flex grid where I have to show different Items on a single cell (one or more button, some label). The number of item can change on different cells so is not possible to create a predefined data source. So I am looking how to setup
    a simple usecontrol that can accomodate the button and use this as column template.
    I have two question:
    1)how can I make the usercontrol able to grow up as the number of button increase and how can I make the datagrid row height "autosize" to accomodate the usercontrol and show all the content
    2) how can I add a empty row on the datagrid and access a single cell (and the usercontrol) to set and read its property.
    I've also tried to do this using a simple wpf grid but its miss many things (head and row fixed header, visible grid) 
    Thank you
    Alessandro
    alex

    I have done a part of the work
    I've generated a dataset with few row and set as itemsource to get the rows on the datagrid
    Then I have wrote a small usercontrol with a single button and a  public sub
    public sub set_text(text as string)
    me.button1.text=text
    end sub
    On the grid I've added the usercontrol as celltemplate
    <DataGridTemplateColumnHeader="Mycontrol1">
    <DataGridTemplateColumn.CellTemplate>
    <DataTemplate>
    <local:UserControl1x:Name="controllo1"/>
    </DataTemplate>
    </DataGridTemplateColumn.CellTemplate>
    Then with this code I can call the set_text sub of a single control on a cell:
    Dimobj
    AsContentPresenter=
    griglia.Columns(2).GetCellContent(griglia.Items(1))
    DimmyDataTemplate = obj.ContentTemplate
    Dimtarget
    = CType(myDataTemplate.FindName("controllo1",
    obj), UserControl1)
     target.Set_text("text to show")
    All work fine till this point.
    I have 2 question:
    1)how can I handle events from my usercontrol (ex. user click a button?)
    2) how can I dinamically add column using the prevous template? Is possible to manipulate direclty the xaml or the only way is to use
    griglia.Columns.Add() ...
    Thank you.
    alex

  • How to hide blank columns in datagrid?

    Hi,
    I have a datagrid nicely populated with data.
    But I have some colums which are blank (the columns have a
    Header but the rest of its rows are blank).
    I want to hide these columns so that users can't see them.
    Note that the blank columns are not fixed. Sometimes it can
    be that a column is blank but at other times it can be filled.
    So I cannot use... "<... visible=false>
    I need to loop thru the columns and then hide the blank
    columns.
    Anyone has an idea how to code for this loop.
    Thx

    Well..from what i know, the datagrid supports the syntax to
    allow for you to specify the columns explicitly through the
    DataGridColumn. Done like this
    <mx:datagrid>
    <mx:columns>
    <mxdatagridcolumn datafield = "Column 1 name" ..>
    <mxdatagridcolumn datafield = "" ..>
    <mxdatagridcolumn datafield = "" ..>
    </mx:columns>
    </mx:datagrid>
    why dont you specify the columns you want using this. that
    way, if there is no data in the colums, that column just wont show.
    Hope i am understanding you right when you say hide blank
    columns

  • How to save the edited datagrid using array collection?

    <?xml version="1.0" encoding="utf-8"?>
    <s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
                        xmlns:s="library://ns.adobe.com/flex/spark"
                        xmlns:mx="library://ns.adobe.com/flex/mx"
                        title="demo2">
              <fx:Declarations>
                        <!-- Place non-visual elements (e.g., services, value objects) here -->
              </fx:Declarations>
              <fx:Script>
                        <![CDATA[               
                                  import mx.collections.ArrayCollection;
                                  import mx.events.FlexEvent;
                                  import spark.components.gridClasses.IGridItemEditor;
                                  import spark.components.gridClasses.IGridItemRenderer;
                                  import spark.events.GridItemEditorEvent;
                                  [Bindable]
                                  private var myDP:ArrayCollection = new ArrayCollection([
                                            {label1:"Day1 ", label2:" Sub1", label3:"Sub2 ", label4:"Sub3 ", label5:"Sub4 ", label6:"Sub5 ", label7:"Sub6 "},
                                            {label1:"Day2 ", label2:" Sub1", label3:"Sub2 ", label4:"Sub3 ", label5:"Sub4 ", label6:"Sub5 ", label7:"Sub6 "},
                                            {label1:"Day3 ", label2:" Sub1", label3:"Sub2 ", label4:"Sub3 ", label5:"Sub4 ", label6:"Sub5 ", label7:"Sub6 "},
                                            {label1:"Day4 ", label2:" Sub1", label3:"Sub2 ", label4:"Sub3 ", label5:"Sub4 ", label6:"Sub5 ", label7:"Sub6 "},
                                            {label1:"Day5 ", label2:" Sub1", label3:"Sub2 ", label4:"Sub3 ", label5:"Sub4 ", label6:"Sub5 ", label7:"Sub6 "},
                                            {label1:"Day6 ", label2:" Sub1", label3:"Sub2 ", label4:"Sub3 ", label5:"Sub4 ", label6:"Sub5 ", label7:"Sub6 "}
                                  protected function myDG_gridItemEditorSessionSaveHandler(event:GridItemEditorEvent):void
                                            // TODO Auto-generated method stub
                                  protected function button1_clickHandler(event:MouseEvent):void
                                            // TODO Auto-generated method stub
                                            navigator.popView();
                                  protected function button2_clickHandler(event:MouseEvent):void
                                            // TODO Auto-generated method stub
                                            myDG.editable=false;
                                            myDP
                                  protected function myDG_exitStateHandler(event:FlexEvent):void
                                            // TODO Auto-generated method stub
                        ]]>
              </fx:Script>
              <s:DataGrid id="myDG" x="10" y="45" width="460" height="240" dataProvider="{myDP}"
                                            editable="true" exitState="myDG_exitStateHandler(event)" fontSize="11"
                                            gridItemEditorSessionSave="myDG_gridItemEditorSessionSaveHandler(even t)"
                                            rowHeight="30" variableRowHeight="true" selectionMode="singleCell" >
                        <s:columns>
                                  <s:ArrayList>
                                            <s:GridColumn dataField="label1" headerText="day" editable="false" />
                                            <s:GridColumn dataField="label2" headerText="9-10am"/>
                                            <s:GridColumn dataField="label3" headerText="10-11am"/>
                                            <s:GridColumn dataField="label4" headerText="11am-12noon"/>
                                            <s:GridColumn dataField="label5" headerText="1-2pm"/>
                                            <s:GridColumn dataField="label6" headerText="2-3pm"/>
                                            <s:GridColumn dataField="label7" headerText="3-4pm"/>            
                                  </s:ArrayList>
                        </s:columns >
              </s:DataGrid>
              <s:Button x="404" y="10" width="53" height="27" label="Back" click="button1_clickHandler(event)"
                                    fontSize="13"/>
              <s:Button x="24" y="10" width="56" height="27" label="Save" click="button2_clickHandler(event)"
                                    fontSize="14"/>
    </s:View>
    please help me with this code...i dontknow how to save the data edited in the datagrid back to my arrayollection!!!

    please help with this......

  • How do I take a datagrid row and put in textInput

    On a search form we have a datagrid that will be populated from a database.  My task is to take the row a user clicks on to populate forms with the data.  Essentially this is taking one row and putting each field into its own textInput control.
    Each of the controls are linked to an XML tag:
    <mx:XML id="dmSearch">
        <data>
            <SearchResults>
                <result>
                </result>
            </SearchResults>
            <SearchCriteria>
            </SearchCriteria>
            <RecProcess>
                <ADDRESS />
                <AGE />
            </RecProcess>
    So the "ADDRESS" is bound:
                        <mx:FormItem id="dtAddress"
                            label="Address"
                            y="35" x="5"
                            width="275"
                            horizontalAlign="right">
                            <mx:TextInput id="RECPROVIDERADDRESS"
                                text="{dmSearch.RecProcess.RECPROVIDERADDRESS}"
                                change="dmSearch.RecProcess.RECPROVIDERADDRESS=RECPROVIDERADDRESS.text; lcConnector.setDirty();"
                                width="140"
                                maxChars="50"/>
                        </mx:FormItem>
    I want to pull the data from this grid:
                        <mx:Form id="searchResults"
                            horizontalCenter="0">
                            <mx:FormItem id="lblSearchResults"
                                label="Search Results" indicatorGap="0">
                                <mx:DataGrid id="dgSearchResults"
                                    click="dataGridClicked()">
                                    <mx:columns>
                                        <mx:DataGridColumn id="colSODC"
                                            dataField="{dmSearch.SearchResults.SODC}"
                                            headerText="SODC"
                                            headerWordWrap="false" />
                                        <mx:DataGridColumn id="colLastName"
                                            dataField="{dmSearch.SearchResults.LASTNAME}"
                                            headerText="Last Name"
                                            headerWordWrap="false" />
                                        <mx:DataGridColumn id="colFirstName"
                                            dataField="{dmSearch.SearchResults.FIRSTNAME}"
                                            headerText="First Name"
                                            headerWordWrap="false" />
                                        <mx:DataGridColumn id="colMHDDID"
                                            dataField="{dmSearch.SearchResults.MHDDID}"
                                            headerText="MHDDID"
                                            wordWrap="false" />
                                        <mx:DataGridColumn id="colRIN"
                                            dataField="{dmSearch.SearchResults.RIN}"
                                            headerText="RIN"
                                            wordWrap="false" />
                                        <mx:DataGridColumn id="colSSN"
                                            dataField="{dmSearch.SearchResults.SSN}"
                                            headerText="SSN"
                                            wordWrap="false" />
                                    </mx:columns>
                                </mx:DataGrid>
                            </mx:FormItem>
                        </mx:Form>
    The datagrid doc at http://livedocs.adobe.com/flex/3/html/help.html?content=dpcontrols_6.html doesn't seem to cover this at all.

    Hi, Greg.
    Each of the textInput items are bound to an XML item:
                        <mx:FormItem id="gWorkPhone"
                            label="Work Phone"
                            x="5"
                            width="250"
                            horizontalAlign="right">
                            <mx:TextInput id="WORKPHONE"
                                text="{dmResults.WORKPHONE}"
                                change="dmResults.WORKPHONE=WORKPHONE.text; lcConnector.setDirty();"
                                width="115"
                                maxChars="50"/>
                        </mx:FormItem>
    (I changed the name in trying to work this out.  I created two XML items (dmSearch and dmResults) which I assume is OK.)
    The item will either contain (through some magic I don't understand yet) the data from the user selected datagrid or blanks for input of new records.  The grid items are filtered based on the search function (resulting in an error):
                var psrSODC:String = dgSearchResults.selectedItem.colSODC as String;
               if (psrSODC != null && psrSODC.length > 0)
                    XMLRecord = dmResults(SODC == psrSODC);
    There are several of these statements as the user might enter 1 to n criteria.  Is this the way to filter the input grid to one record?  And how does "XMLRecord" know the layout of the file?

  • How to disable columns while displaying

    Hi,
    How to disable columns from the page which we don't want to show to the users.For example Users will search by "Invoice No" but they don't want to see again Invoice No on the results page.
    Appreciate your quick response.
    Thks.

    Check out Dev Guide
    Chapter 4: Implementing Specific UI Features -> Search -> Declarative Implementation: Auto Customization Criteria
    With this Query Bean option you can separate the Search region from the results table. You map the items in the search region to the items in the result region. You can mark the item in the result table as Rendered=No. OAF will run the query against this item even though it's not displayed.

Maybe you are looking for