Ordering datagrid rows by dragging rows

Hi all,
I have a normal dg which is pulling data from MySQL db and
i'm trying
to figure out the best way to allow users to drag the rows to
re-order
as per however they may want it..
This is what I thought buy some feedback would be great!
1. Add 'order' column to sql db
2. Set inital order for each row
3. sort by order desc when pulling db into dg
4. Create function to:
a. when a user drops a row into desired position make each
rows
order = each rows index
b. update mysql db when all changes are complete
I also thought, maybe remember oldOrder val, + 1 to each
order value
from point of insertion until order = oldOrder??
Obviously this method has issues when the # of rows grows..
so thats
why I would love some help with this! there must be a better
way :)
Thanks in advance!
Matt (OzFlex Adobe User Group - Melbourne)

Hi all,
I have a normal dg which is pulling data from MySQL db and
i'm trying
to figure out the best way to allow users to drag the rows to
re-order
as per however they may want it..
This is what I thought buy some feedback would be great!
1. Add 'order' column to sql db
2. Set inital order for each row
3. sort by order desc when pulling db into dg
4. Create function to:
a. when a user drops a row into desired position make each
rows
order = each rows index
b. update mysql db when all changes are complete
I also thought, maybe remember oldOrder val, + 1 to each
order value
from point of insertion until order = oldOrder??
Obviously this method has issues when the # of rows grows..
so thats
why I would love some help with this! there must be a better
way :)
Thanks in advance!
Matt (OzFlex Adobe User Group - Melbourne)

Similar Messages

  • 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.

  • How to preset the order of rows in the outer query of a correlated query ?

    Good morning,
    I have the following simple query:
    select empno,
           ename,
           sal,
           sum(case
                 when rn = 1 then sal
                 else -sal
               end) over (order by sal, empno) as running_diff
       from (
             select empno,
                    ename,
                    sal,
                    row_number() over (order by sal, empno) as rn
               from emp
              where deptno = 10
             );That calculates a running difference and uses "row_number() over (...)" which is an Oracle specific feature to do so. It yields the following result (which we will consider correct):
         EMPNO ENAME             SAL RUNNING_DIFF
          7934 MILLER           1300         1300
          7782 CLARK            2450        -1150
          7839 KING             5000        -6150I wanted to come up with a solution that was not Oracle specific different solution. I tried the following code:
    (EDIT: after additional thought, that code is totally different in meaning and will never come close, to the above result. Consider it wrong and ignore this attempt altogether.)
    select a.empno,
           a.ename,
           a.sal,
           (select case
                     when a.empno = min(b.empno) then sum(b.sal)
                     else sum(-b.sal)
                   end
              from emp b
             where b.empno <= a.empno
               and b.deptno = a.deptno) as running_diff
      from emp a
    where a.deptno = 10;but the result is
         EMPNO ENAME             SAL RUNNING_DIFF
          7782 CLARK            2450         2450
          7839 KING             5000        -7450
          7934 MILLER           1300        -8750which is a long way from the original result. I've tried everything I could think of to order the rows before the running difference is calculated but, have been unsuccessful.
    Is there a way to change this second query --(without using Oracle specific features)-- without using windowing features that would yield the same result as the first query ?
    Rephrase of the above question:
    Is there a way, using plain vanilla SQL (that is aggregate functions and set operations such as joins and unions) to create a query that yields the same result as the first one ?
    Also, this is not for production code. This is simply an exercise in set manipulation that I'd like to see a solution for.
    Thank you for your help,
    John.
    Edited by: 440bx - 11gR2 on Jul 18, 2010 12:50 AM - correct "ho w" to "How"
    Edited by: 440bx - 11gR2 on Jul 18, 2010 1:42 AM - struck out all references to row_number and windowing features being Oracle specific features.
    Edited by: 440bx - 11gR2 on Jul 18, 2010 3:51 AM - Noted that my try is woefully wrong and restated the objective to make it clearer.

    Hi, John,
    One way to get a running total (which is basically what you want) is to do a self-join. Join each row (let's call it the current row, or c) to itself and everything that came before it (let's call this the previous row, or p), and do a regular aggregate SUM, like this:
    WITH     got_base_sal     AS
         SELECT       deptno
         ,       2 * MIN (sal)     AS base_sal
         FROM       scott.emp
         GROUP BY  deptno
    SELECT       c.deptno
    ,       c.empno
    ,       c.ename
    ,       c.sal
    ,       b.base_sal - SUM (p.sal)     AS running_diff
    FROM       scott.emp     c
    JOIN       scott.emp     p     ON     c.deptno     = p.deptno
                        AND     (     c.sal     > p.sal
                             OR     (     c.sal     =  p.sal
                                  AND     c.empno     >= p.empno
    JOIN       got_base_sal     b     ON     c.deptno     = b.deptno
    WHERE       c.deptno     IN (10)
    GROUP BY  c.deptno
    ,       c.empno
    ,       c.ename
    ,       c.sal
    ,       b.base_sal
    ORDER BY  c.deptno
    ,       running_diff     DESC
    ;Output:
        DEPTNO      EMPNO ENAME             SAL RUNNING_DIFF
            10       7934 MILLER           1300         1300
            10       7782 CLARK            2450        -1150
            10       7839 KING             5000        -6150I said you basically want a runninng total. There are two differences between a running total and your requirements
    (1) You want to have a total of the negative of what's in the table. That's trivial: use a minus sign.
    (2) You want the first item to count as positive instead of negative. That's not so trivial. The query above counts all sals as negative, but adds an offset so that it appears as if the first item had been counted as positive, not negative.
    You didn't say what you want to do in case of a tie (two or more rows having the same sal). The query above uses empno as a tie-breaker, so that all sals are calculated as if they were distinct. This is similar to what analytic functions do when the windowing is based on rows. If you want something similar to windowing by range, that might actually be simpler.
    The query above calculates a separate running_diff for each deptno, similar to "PARTITION BY deptno" in analytic functions. You happen to be interested in only one deptno right now, but you can change the main query's WHERE clause, or omit it, and the query will still work. If you don't want this feature (analagoud to not having any PARTITION BY), it's easy to modify the query.
    You could also get these results using a recursive WITH clause. That meets the criteria of avoiding analytic functions and Oracle-specific features, but not the one about using only plain, simple SQL features.

  • Ordering of rows are showing difference when migration db from 9.2.0.8.0-32bits(windows 3) to 10.2.0.5.0 - 64bit(windows 8)?

    Dears,
    After migration(via export/import), we are facing ordering of rows are mis-match  in these two databases.
    the following same query I am running on the these two databases. but different output. output are below.
    [CODE]
    SELECT ROWNUM AS RowNo, TBL1.*
      FROM (    SELECT COUNT (PG_ID) AS TotalCount,
                     PG_DESC AS PageDescription,
                     CURR_EPR_QUEUE AS CurrentQueue,
                     PG_NME AS PageName,
                     QUEUE_TYP_CDE AS QueueTypeCode,
                     PG_ID AS PageID
                FROM SASV_TB_CNT_APPL_JUDG_2----this is a view
               WHERE (CURR_EPR_QUEUE = 'test' AND QUEUE_TYP_CDE = '01')
                     OR (    JUD_RACIF_ID = 'test'
                         AND CMPLTD_IND = '0'
                         AND DSPLY_IND = '1')
                        AND TOTAL_CNT > 0
            GROUP BY PG_ID,
                     PG_NME,
                     PG_DESC,
                     CURR_EPR_QUEUE,
                     QUEUE_TYP_CDE            
                      ) TBL1
    [/CODE]
    output- from
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
    TNS for 32-bit Windows: Version 9.2.0.8.0 - Production
    1
    7
    Other Documents(Hearing)
    askinj
    HG01_Other_Documents
    1
    HG01-TB02
    2
    3
    Pending Award
    askinj
    HG01_Pending_Order
    1
    HG01-TB05
    3
    19
    Motion(ADR)
    askinj
    MD01_Motion
    1
    MD01-TB01
    4
    5
    Other Documents(ADR)
    askinj
    MD02_Other_Documents
    1
    MD01-TB02
    5
    1
    Scheduling(ADR)
    askinj
    MD01_Scheduling
    1
    MD01-TB03
    6
    8
    Mediations
    askinj
    MD01_Mediations
    1
    MD01-TB04
    output from--
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
    TNS for 64-bit Windows: Version 10.2.0.5.0 - Production
    1
    3
      Pending Award
    askinj
    HG01_Pending_Order
    1
    HG01-TB05
    2
    7
      Other   Documents(Hearing)
    askinj
    HG01_Other_Documents
    1
    HG01-TB02
    3
    8
      Mediations
    askinj
    MD01_Mediations
    1
    MD01-TB04
    4
    5
    Other Documents(ADR)
    askinj
    MD02_Other_Documents
    1
    MD01-TB02
    5
    1
    Scheduling(ADR)
    askinj
    MD01_Scheduling
    1
    MD01-TB03
    6
    19
    Motion(ADR)
    askinj
    MD01_Motion
    1
    MD01-TB01
    the views query is below
    SASV_TB_CNT_APPL_JUDG_2
    [code]
    (SELECT spm.PG_ID,
               spm.PG_NME,
               spm.PG_DESC,
               DECODE (TAJD.ABS_IND, 1, GUEST_JUD_ID, JUDG_ID) CURR_EPR_QUEUE,
               QUEUE_TYP_CDE,
               1 "TOTAL_CNT",
               DECODE (TAJD.ABS_IND, 1, GUEST_JUD_ID, JUDG_ID) JUD_RACIF_ID,
               CMLTD_IND CMPLTD_IND,
               NULL DSPLY_IND
          FROM SA_PG_MSTR SPM, TMST_APPEAL_JUDGE_DETAIL TAJD, SA_WRK_ITM SWI
         WHERE     SWI.WRK_ITM_ID = TAJD.WRK_ITM_ID
               AND swi.tb_pg_id = spm.pg_id
               AND SWI.CURR_EPR_QUEUE = 'AppellateCommonJudgeUser'
               AND CMLTD_IND = '0'
               AND tajd.LEAD_JUD_IND != '3'
        UNION ALL
        SELECT spm.PG_ID,
               spm.PG_NME,
               spm.PG_DESC,
               CURR_EPR_QUEUE,
               QUEUE_TYP_CDE,
               1 "TOTAL_CNT",
               CURR_EPR_QUEUE judg_racif_id,
               '0' CMPLTD_IND,
               NULL DSPLY_IND
          FROM SA_PG_MSTR spm, SA_WRK_ITM SWI
         WHERE SCCS_IND = '1' AND SWI.ACTIVE = '1' AND spm.pg_id = swi.tb_pg_id
        UNION ALL
        SELECT spm.PG_ID,
               spm.PG_NME,
               spm.PG_DESC,
               CURR_EPR_QUEUE,
               QUEUE_TYP_CDE,
               1 "TOTAL_CNT",
               JUD_RACIF_ID,
               CMPLTD_IND,
               DSPLY_IND
          FROM ST_WRK_ITM_JUD_DTL SWIJD, SA_WRK_ITM SWI, SA_PG_MSTR spm
         WHERE     SWI.WRK_ITM_ID = SWIJD.WRK_ITM_ID
               AND swi.tb_pg_id = spm.pg_id
               AND swi.queue_typ_cde IN ('01', '05')
               AND swi.dup_ind <> 1);
    [code]
    parameters in 9i are belows
    [code]
    aq_tm_processes    1
    background_dump_dest    D:\oracle\admin\TEST\bdump
    compatible    9.2.0.0.0
    cursor_sharing    similar
    db_block_size    8192
    db_cache_size    947912704
    db_domain
    db_file_multiblock_read_count    16
    db_keep_cache_size    167772160
    db_name    TEST
    fast_start_mttr_target    300
    hash_area_size    1073741824
    hash_join_enabled    TRUE
    instance_name    TEST
    java_pool_size    67108864
    job_queue_processes    10
    large_pool_size    109051904
    local_listener    (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.2.51)(PORT=1521))
    log_archive_format    %t_%s.dbf
    log_archive_start    TRUE
    log_buffer    26214400
    open_cursors    700
    optimizer_index_caching    80
    optimizer_index_cost_adj    20
    optimizer_mode    FIRST_ROWS
    pga_aggregate_target    1468006400
    processes    800
    query_rewrite_enabled    TRUE
    remote_login_passwordfile    EXCLUSIVE
    session_cached_cursors    400
    sga_max_size    2149134244
    shared_pool_size    788529152
    sort_area_size    1073741824
    star_transformation_enabled    FALSE
    timed_statistics    TRUE
    undo_management    AUTO
    undo_retention    10800
    undo_tablespace    UNDOTBS1
    utl_file_dir    H:\ICMS_TO_GO
    workarea_size_policy    AUTO
    [code]
    parameters in 10 are belows
    [code]
    aq_tm_processes    1
    compatible    10.2.0.5.0
    db_block_size    8192
    db_domain
    db_file_multiblock_read_count    16
    db_name    TEST
    db_recovery_file_dest    C:\oracle/flash_recovery_area
    db_recovery_file_dest_size    171798691840
    dispatchers    (PROTOCOL=TCP) (SERVICE=TESTXDB)
    job_queue_processes    10
    log_archive_format    ARC%S_%R.%T
    open_cursors    800
    open_links    10
    open_links_per_instance    10
    pga_aggregate_target    3984588800
    processes    1200
    recyclebin    OFF
    remote_login_passwordfile    EXCLUSIVE
    session_cached_cursors    400
    sessions    1325
    sga_max_size    10485760000
    sga_target    10485760000
    undo_management    AUTO
    undo_tablespace    UNDOTBS1
    utl_file_dir    H:\ICMS_TO_GO
    optimizer_dynamic_sampling    2
    optimizer_features_enable    10.2.0.5
    optimizer_index_caching    80
    optimizer_index_cost_adj    20
    optimizer_mode    FIRST_ROWS
    optimizer_secure_view_merging    FALSE
    plsql_optimize_level    2
    [code]
    where can we look into for this issue? actually we need rows will be the same ordering as it was in 9i.
    we are facing this problem in lot of queries, this is a sample one.
    Regards
    Halim

    Hi Jgarry,
    why do you need a particular physical order?
    Actually i don't know the .net application behave or code yet . but after migration, I am facing this issue.
    one more thing we changed the server machine so Is there any registry parameter (in windows) related to this. Have you any idea.
    the application is running since 8 years and I think nobody can rely on implicit data distribution arising from how the data is entered to develop a application.
    Hi Hoek,
    According to Oracle White Paper(page 17), If I change below parameter. Is there any hope to get same order.
    "After you upgrade to Oracle Database 10g, if you
    wanted to revert back to 9.2 optimizer behavior you can set
    OPTIMIZER_FEATURES_ENABLE = 9.2.0 "
    Regards
    Halim

  • Order of rows retrieved from collection

    hi -- If I do not specify an ORDER BY clause when selecting rows from a collection, is
    there any pre-defined order in which they'll be returned? (Eg perhaps in the order each
    row is added to the collection...)
    I ask because I've been using a particular collection for ages, but forgot to specify
    an order when querying from it. Just today it returned the rows in a different order
    than it has in the past -- only once -- and then they were returned as before.
    The order I want -- and have been getting -- is the order in which they're added to the collection.
    Will the 'no query transformation' hint accomplish this, or do I need a member that specifies the order?
    Thanks,
    C

    Never mind... got it.

  • How to display data in ComboBox when click on DataGrid Row.

    Hi!
         I am new to Adobe Flex. I am building one Project that was related to Comapny and Customer. First I created Company Master. Then I create Customer Master successfully and My Backkend is SQLite Database.
         My Problem is I have two files one is CustomerMaster and second one is CustomerForm.
         In CustomerMaster I have a datagrid in that data was displaying thru Array Collection. When ever we doublick on datagrid row it's displayed a CompanyForm. CompanyForm  contains TextFiled and ComboBox. TextFiled populating data but Combobox doesnot. It display always prompt message.
          Please help.
    Thanks,
    Sree Kumar

    Hi! Vibhuti Gosavi,
                          First of all thanks for your quick reply. Already I saw that link.
    Actually, In CustomerForm successfully store the information into the database. While retrieving the data problem cames. Sample Code:
    CustomerMaster:
    private function createItem():void
                                            openTab(new Object());
                                  public function openTab(customer:Object):void
                                            var children:Array = tn.getChildren();
                                            var length:int = children.length;
                                            for (var i:int = 0; i<length; i++)
                                                      if (children[i].customer.customerId == customer.customerId)
                                                                tn.selectedIndex = i;
                                                                return;
                                            var form:CustomerForm = new CustomerForm();
                                            tn.addChild(form);
                                            form.customer = customer;
                                            form.dao = dao;
                                            form.addEventListener(CustomerEvent.CREATE, customerChangeHandler),
                                                      form.addEventListener(CustomerEvent.UPDATE, customerChangeHandler),
                                                      form.addEventListener(CustomerEvent.DELETE, customerChangeHandler),
                                                      tn.selectedChild = form;
                                  private function customerChangeHandler(event:CustomerEvent):void
                                            customerArrayList = dao.findByCustomerAll();
                                            if (event.type == CustomerEvent.DELETE)
                                                      tn.removeChild(event.target as CustomerForm);
                        ]]>
              </fx:Script>
              <mx:Canvas id="container" left="12" right="12" top="12" bottom="12">
                        <mx:Canvas left="0" top="2" right="0" height="33">
                                  <mx:Button id="AddCustomer" x="1" width="108" height="32" click="createItem()"
                                                         icon="@Embed('assets/icon_plus.png')" label="Add Customer" toolTip="Add Customer"
                                                         verticalCenter="-1"/>
                        </mx:Canvas>
                        <code:SuperTabNavigator id="tn" x="0" y="39" width="681" height="197"/>
                        <mx:DataGrid id="customerList" x="1" y="262" width="680" height="231"
                                                       dataProvider="{customerArrayList}"
                                                       doubleClick="openTab(customerList.selectedItem)" doubleClickEnabled="true">
                                  <mx:columns>
                                            <mx:DataGridColumn dataField="customerId" headerText="Id"/>
                                            <mx:DataGridColumn dataField="customerName" headerText="Name" />
                                            <mx:DataGridColumn dataField="companyName" headerText="companyName" />
                                  </mx:columns>
                        </mx:DataGrid>
              </mx:Canvas>
    CustomerForm:
    public function set customer(customer:Object):void
                                            this._customer = customer;
                                  public function get customer():Object
                                            return this._customer;
                                  private function saveCustomer():void
                                            if (Validator.validateAll(customerValidators).length>0)
                                                      return;
                                            _customer.customerName = customerName.text;
                                             _customer.companyName = companyName.text;
                                            if (_customer.customerId > 0)
                                                      updateCustomer();
                                            else
                                                      insertCustomer();
                                  private function insertCustomer():void
                                            try
                                                      Alert.show(_customer.normalPkts);
                                                      dao.insertCustomer(_customer);
                                                      customerId.text = _customer.customerId;
                                                      dispatchEvent(new CustomerEvent(CustomerEvent.CREATE, _customer, true));
                                                      var alertText:String="Company Created Successfully!";
                                                      Alert.show(alertText,"",4,null,null,ConfirmMessage);
                                            catch (error:SQLError)
                                                      var alertErrorCreate:String="Company not Created...";
                                                      Alert.show(alertErrorCreate+"\n"+error.details,"",4,null,null,ErrorMessage);
                                  private function updateCustomer():void
                                            try
                                                      dao.updateCustomer(_customer);
                                                      dispatchEvent(new CustomerEvent(CustomerEvent.UPDATE, _customer, true));
                                                      var alertText:String="Company Updated Successfully!";
                                                      Alert.show(alertText,"",4,null,null,ConfirmMessage);
                                            catch (error:SQLError)
                                                      var alertErrorText:String="Company not Updated...";
                                                      Alert.show(alertErrorText+"\n"+error.details,"",4,null,null,ErrorMessage);
                                  private function deleteItem():void
                                            try
                                                      dao.deleteCustomer(_customer);
                                                      dispatchEvent(new CustomerEvent(CustomerEvent.DELETE, _customer, true));
                                            catch (error:SQLError)
                                                      Alert.show(error.details, "Error");
                        ]]>
              </mx:Script>
       <mx:Grid x="10" y="10" width="665" height="130" verticalAlign="middle">
                        <mx:GridRow width="665" height="100%">
                                  <mx:GridItem width="85" height="100%">
                                            <mx:Label width="85" text="Customer Id:"/>
                                  </mx:GridItem>
                                  <mx:GridItem width="115" height="100%">
                                            <mx:TextInput id="customerId" text="{_customer.customerId}" editable="false" width="115"/>
                                  </mx:GridItem>
                                  <mx:GridItem width="102" height="100%">
                                            <mx:Label width="102" text="Company Name:"/>
                                  </mx:GridItem>
                                  <mx:GridItem width="100" height="100%">
                                            <mx:ComboBox id="companyName" dataProvider="{companyIdList}" labelField="companyName"
                                                                           prompt="Select..." text="{_customer.companyName}" width="100"/>
                                  </mx:GridItem>
                          <mx:GridItem width="230" height="100%" horizontalAlign="center" verticalAlign="middle">
                                            <mx:Button label="Save" click="saveCustomer()"/>
                                            <mx:Button label="Delete" click="deleteItem()"/>
                                  </mx:GridItem>
                        </mx:GridRow>
              </mx:Grid>
    =====================================================================
    I have two ArrayCollections 1) companyIdList (CustomerForm)
                                              2) customerArrayList(CustomerMaster)
    please go through the bold text. Please focus on two dataProviders. These dataproviders are binding for One Combo Field.
    Thanks,
    Sree Kumar
    Message was edited by: sreekumar1976

  • Insert String array as label content in datagrid row through radio button C# wpf?

    I have written some code for inserting label at runtime having its content set to a string array and then insert that label into a datagrid row . All of this will initiate when certain radiobuttons are checked. code is working perfectly fine. But i need
    to improve this code as i am learning C#, wpf and datagrid. I know there can be a certain way to improve this code. 
    This code will be a nightmare when there are 50 radiobuttons. 
    can it be improve and how it can be? if u can explain that will be very kind of you  
    Xaml Code:
    <Grid>
    <RadioButton x:Name="rb_1" Content="RadioButton" HorizontalAlignment="Left" Margin="351,85,0,0" VerticalAlignment="Top" GroupName="1" />
    <RadioButton x:Name="rb_2" Content="RadioButton" HorizontalAlignment="Left" Margin="351,105,0,0" VerticalAlignment="Top" GroupName="1"/>
    <RadioButton x:Name="rb_3" Content="RadioButton" HorizontalAlignment="Left" Margin="351,120,0,0" VerticalAlignment="Top" GroupName="1" />
    <RadioButton Content="RadioButton" HorizontalAlignment="Left" Margin="351,159,0,0" VerticalAlignment="Top" GroupName="2" />
    <RadioButton x:Name="rb_4" Content="RadioButton" HorizontalAlignment="Left" Margin="351,179,0,0" VerticalAlignment="Top" GroupName="2"/>
    <RadioButton Content="RadioButton" HorizontalAlignment="Left" Margin="351,199,0,0" VerticalAlignment="Top" GroupName="2" />
    <Button Content="Button" HorizontalAlignment="Left" Margin="713,60,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click_2"/>
    <DataGrid x:Name="datagrid_" HorizontalAlignment="Left" Margin="549,85,0,0" VerticalAlignment="Top" Height="253" Width="399" />
    <RadioButton Content="RadioButton" HorizontalAlignment="Left" Margin="351,226,0,0" VerticalAlignment="Top" GroupName="3" />
    <RadioButton x:Name="rb_6" Content="RadioButton" HorizontalAlignment="Left" Margin="351,246,0,0" VerticalAlignment="Top" GroupName="3"/>
    <RadioButton Content="RadioButton" HorizontalAlignment="Left" Margin="351,266,0,0" VerticalAlignment="Top" GroupName="3" />
    <RadioButton Content="RadioButton" HorizontalAlignment="Left" Margin="351,298,0,0" VerticalAlignment="Top" GroupName="4" />
    <RadioButton x:Name="rb_8" Content="RadioButton" HorizontalAlignment="Left" Margin="351,318,0,0" VerticalAlignment="Top" GroupName="4"/>
    <RadioButton Content="RadioButton" HorizontalAlignment="Left" Margin="351,338,0,0" VerticalAlignment="Top" GroupName="4" />
    </Grid>
    Code Behind:
    public partial class MainWindow : Window
    public MainWindow()
    InitializeComponent();
    DataTable dt;
    DataRow dr;
    string[] str = new string[4];
    int location = 0;
    int count = 0;
    private void Window_Loaded(object sender, RoutedEventArgs e)
    dt = new DataTable("emp");
    DataColumn dc1 = new DataColumn("Factors", typeof(string));
    DataColumn dc2 = new DataColumn("Non_Compliant", typeof(string));
    dt.Columns.Add(dc1);
    dt.Columns.Add(dc2);
    datagrid_.ItemsSource = dt.DefaultView;
    private void Button_Click_2(object sender, RoutedEventArgs e)
    if (count >= 1)
    datagrid_.ItemsSource = dt.DefaultView;
    dt.Clear();
    str[0] = "Load Path1";
    str[1] = "Load Path2";
    str[2] = "Load Path3";
    str[3] = "Load Path4";
    int j = 0;
    if (rb_2.IsChecked == true)
    j = 0;
    int k = 0;
    dr = dt.NewRow();
    Label label = new Label();
    label.Height = 28;
    label.Width = 100;
    label.HorizontalAlignment = HorizontalAlignment.Center;
    label.VerticalAlignment = VerticalAlignment.Center;
    label.Content = str[j];
    dr[k] = label.Content;
    dt.Rows.Add(dr);
    datagrid_.ItemsSource = dt.DefaultView;
    location += 34;
    if (rb_4.IsChecked == true)
    j = 1;
    int k = 0;
    dr = dt.NewRow();
    Label label = new Label();
    label.Height = 28;
    label.Width = 100;
    label.HorizontalAlignment = HorizontalAlignment.Center;
    label.VerticalAlignment = VerticalAlignment.Center;
    label.Content = str[j];
    dr[k] = label.Content;
    dt.Rows.Add(dr);
    datagrid_.ItemsSource = dt.DefaultView;
    location += 34;
    if (rb_6.IsChecked == true)
    j = 2;
    int k = 0;
    dr = dt.NewRow();
    Label label = new Label();
    label.Height = 28;
    label.Width = 100;
    label.HorizontalAlignment = HorizontalAlignment.Center;
    label.VerticalAlignment = VerticalAlignment.Center;
    label.Content = str[j];
    dr[k] = label.Content;
    dt.Rows.Add(dr);
    datagrid_.ItemsSource = dt.DefaultView;
    location += 34;
    if (rb_8.IsChecked == true)
    j = 3;
    int k = 0;
    dr = dt.NewRow();
    Label label = new Label();
    label.Height = 28;
    label.Width = 100;
    label.HorizontalAlignment = HorizontalAlignment.Center;
    label.VerticalAlignment = VerticalAlignment.Center;
    label.Content = str[j];
    dr[k] = label.Content;
    dt.Rows.Add(dr);
    datagrid_.ItemsSource = dt.DefaultView;
    location += 34;
    count++;

    @Usamakhan1990,
    Use usercontrol with label and checkbox is reasonable for a datagrid control if you don't want to have too much code for those radio buttons. So I agree with andy here with that usercontrol.
    So is it required that your radiobutton should be outside the datagrid?
    Anyway, I think you already know that you can bind data to columns yourself. So please check the following thread:
    http://stackoverflow.com/questions/22922533/how-do-i-automagically-bind-a-string-array-to-a-wpf-datagrid
    <DataGrid Name="_dataGrid" Grid.Row="0" AutoGenerateColumns="False">
    <DataGrid.Columns>
    <DataGridTextColumn Header="Column 1" Binding="{Binding [0]}"/>
    <DataGridTextColumn Header="Column 2" Binding="{Binding [1]}"/>
    </DataGrid.Columns>
    </DataGrid>
    Or define the columns from code, in case you have dynamic number of columns, for example :
    string[][] array = fs.CSVToStringArray();
    for (int i = 0; i < array[0].Length; i++)
    var col = new DataGridTextColumn();
    col.Header = "Column " + i;
    col.Binding = new Binding(string.Format("[{0}]", i));
    _dataGrid.Columns.Add(col);
    this.ExternalData._dataGrid.ItemsSource = array;
    And for Radio button part, please see here:
    http://stackoverflow.com/questions/397556/how-to-bind-radiobuttons-to-an-enum
    Best regards,
    Barry
    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.

  • TIPS(64) : ORDERING 된 상위 "N" ROWS 만 RETRIEVE 하는 SQL문

    제품 : SQL*PLUS
    작성날짜 : 2002-12-20
    ORDERING 된 상위 "N" ROWS 만 RETRIEVE 하는 SQL문
    ===============================================
    PURPOSE
    다음은 특정 Column 으로 Ordering 된 상위 "n" rows 만 Return 하기 위한
    간단한 SQL 문을 소개한다.
    Explanation
    Example
    SELECT *
    FROM table A
    WHERE n >= (SELECT COUNT(*)
    FROM table B
    WHERE B.column >= A.column)
    ORDER BY column DESC;
    예) Emp Table 에서 Salary 가 많은 상위 5명만 구하는 SQL 문
    SQL> select empno,ename,sal
    2 from emp A
    3 where 5 >= (select count(*)
    4 from emp B
    5 where B.sal >= A.sal)
    6 order by sal desc
    7 /
    EMPNO ENAME SAL
    7839 KING 5000
    7788 SCOTT 3000
    7902 FORD 3000
    7566 JONES 2975
    7698 BLAKE 2850
    5 rows selected.
    ->Oracle 8i 이상인 경우
    다음과 같이 간단히 query 할수 있다.
    1 select empno,ename,sal
    2 from (select * from emp order by sal desc)
    3* where rownum <= 5;
    위의 예는 상위 "n" Rows 만 정확히 Return 한다. 그러나 중복된
    Column Value 를 가진다면 다음의 예를 고려해 보아야 할 것이다.
    SELECT *
    FROM table A
    WHERE n >= (SELECT COUNT(DISTINCT column)
    FROM column B
    WHERE B.column >= A.column)
    ORDER BY column DESC;
    예)
    SQL> select empno,ename,sal
    2 from emp A
    3 where 5 >= (select count(distinct sal)
    4 from emp B
    5 where B.sal >= A.sal)
    6 order by sal desc
    7 /
    EMPNO ENAME SAL
    7839 KING 5000
    7788 SCOTT 3000
    7902 FORD 3000
    7566 JONES 2975
    7698 BLAKE 2850
    7782 CLARK 2450
    6 rows selected.
    Reference Documents
    none

  • How to add event listener to datagrid ROW

    I need to know if it is possible to have the datagrid rows execute a state change.
    For example: I have a datagrid populated with various items, when one row is selected I want it to change the state of a part of the canvas it is in.
    How is this possible? I can not give the row an id so I would not be able to say "when row is selected change state" because there is no way to tell what row is selected.
    Help please. Thanks.

    See Flex 4 and MXDataGridItemRenderer.

  • Incorrect sort order of rows in Purchase Order based on Sales Order

    Hello Experts.
    I have this problem on SAP B1 8.81 PL 04:
    I create a Purchase Order based on a Sales Order with 10 item rows, ticking the purchase order box in the logistic tab.
    The sort order of rows is different between PO and SO.
    I need the same order of SO on PO.
    Is there something I can do or it's a problem of this patch?
    I saw the Sap Note nr. 824822 but it's related to SAP B1 version 2004 A...
    Regards
    Silvia Reggiani
    Edited by: Silvia Reggiani on Oct 11, 2011 12:26 PM

    Hi,
    Are you able to reproduce the issue in the DEMO Database on the 8.81 PL04?
    Also, have you checked the issue in the latest patch of the 8.81?
    Kind Regards,
    Jitin
    SAP Business One Forum Team

  • Analytical function count(*) with order by Rows unbounded preceding

    Hi
    I have query about analytical function count(*) with order by (col) ROWS unbounded preceding.
    If i removed order by rows unbouned preceding then it behaves some other way.
    Can anybody tell me what is the impact of order by ROWS unbounded preceding with count(*) analytical function?
    Please help me and thanks in advance.

    Sweety,
    CURRENT ROW is the default behaviour of the analytical function if no windowing clause is provided. So if you are giving ROWS UNBOUNDED PRECEDING, It basically means that you want to compute COUNT(*) from the beginning of the window to the current ROW. In other words, the use of ROWS UNBOUNDED PRECEDING is to implicitly indicate the end of the window is the current row
    The beginning of the window of a result set will depend on how you have defined your partition by clause in the analytical function.
    If you specify ROWS 2 preceding, then it will calculate COUNT(*) from 2 ROWS prior to the current row. It is a physical offset.
    Regards,
    Message was edited by:
    henryswift

  • Displaying Datagrid Rows Based on User Login Id

    Hey Everyone,
    So the problem I am having is that I am making a product configurator and when a user logs in I want to display there previous creations in a data grid so they can select edit or reorder them....the problem I am having is for some reason I can't get the designs to show up based on specific users...here is the process i am currently using in Flex 4.5
    I create 2 tables in the database (Users and Designs)
         the id for the design is based on the id of the user that created it
    In flex I create 2 php services
         -One generated from the users table for creating a new user for the configurator
         -The other one is generated from the Design table and I use the getAllDesigns(); to display the designs in the data grid
    All of the login info is validated through php files that are used by an httpservice call
    So my idea was to run an if statement to display the designs for specific user, something like this (i know the syntax isn't right this is just to get my idea accross
    Var designId = datagrid.row.id;
    (allready have userId var)
    if(userId != designId)
         row.visible = "false"
    I have tried many different approaches but cant get anything to work
    Any Ideas would be helpful
    Thanks In advance

    Your right, i was trying to wrap my head around that idea earlier but decided to go with this option to just see if i could get this to work then work on the server side filtering...
    How would I do this in theory,
    my thinking is that i query in my php file something like
    SELECT * FROM DESIGNS WHERE DESIGNS.ID = USERS.ID;
    then take the filtered data and pass it to a xml document
    then in flex create an array list out of the xml to insert into the datagrid?
    or do you have a better idea?
    also will that information even be able to be editable because i am parsing the data through the xml?
    Thanks for any input

  • DataGrid row padding?

    Trying to use a DataGrid to display two columns of data.
    However, there is a lot of space between the rows making this
    rather unattractive. Any thoughts or ideas?
    <mx:DataGrid x="10" y="10" borderStyle="none"
    sortableColumns="false" selectable="false" showHeaders="false"
    fontSize="12" color="#000000" fontWeight="normal" width="392"
    height="207">
    <mx:dataProvider>
    <mx:Object Label="Manufacturer" Value="General
    Mills"/>
    <mx:Object Label="Category" Value="Cereal breakfast
    foods"/>
    <mx:Object Label="Description" Value="Toasted whole grain
    oat cereal with kid-friendly ring shape"/> <!-- with
    kid-friendly ring shape -->
    <mx:Object Label="Quantity" Value="425 g Box"/>
    </mx:dataProvider>
    <mx:columns>
    <mx:DataGridColumn dataField="Label" headerText=""
    textAlign="left" width="115"/>
    <mx:DataGridColumn dataField="Value" headerText=""
    textAlign="left" wordWrap="true"/>
    </mx:columns>
    </mx:DataGrid>

    "Phrankie" <[email protected]> wrote in
    message
    news:go4tgo$jra$[email protected]..
    >
    quote:
    Originally posted by:
    ntsiii
    > Did you look for that word ("padding") in the DataGrid
    docs? Combine that
    > with rowHeight, and I think you will be good to go.
    >
    > Tracy
    >
    > Nor have I found a way to lessen the distance between
    the text baseline
    > and
    > the gridline directly below, but I sure would like to!
    The datagrid rows
    > are
    > excessively tall in a number of my projects.
    >
    > Flex/CSS padding doesn't conform entirely to the normal
    HTML/CSS since of
    > the
    > term. For instance, paddingBottom has a fixed lower
    display limit, while
    > paddingTop has no limitation.
    >
    > Additionally, some sort of inheritance causes my CSS
    datagrid padding
    > styles
    > to affect the datagrid rows AND the header ... even when
    I add a
    > headerStyle
    > with its own distinct padding values.
    >
    > This CSS works as expected, though originally I would
    have expected that
    > these
    > padding values would not affect the header:
    >
    > DataGrid {
    > paddingBottom: 10;
    > paddingBottom: 10;
    > headerStyleName: "mydataGridHeaderStyle";
    > }
    >
    > /* However the follow declaration does NOT style the
    datagrid?s header
    > padding
    > independently */
    >
    > .mydataGridHeaderStyle {
    > paddingBottom:2; /*no effect */
    > }
    >
    > Given the following declarations the heading responds as
    expected ... but
    > the
    > datagrid rows only honor paddingTop.
    >
    > DataGrid {
    > paddingTop: -4;
    > paddingBottom: -5;
    > }
    >
    > Perhaps the datagrid row refuse to honor negative
    values, whereas the
    > header
    > complies.
    >
    > A little perplexed here.
    >
    > Suggestions?
    That might be another manifestation of this:
    http://flexdiary.blogspot.com/2008/06/using-css-typeselector-with.html
    HTH;
    Amy

  • Accessing Datagrid row data from within an itemRenderer

    I would like to know how I can access another row's data from within an itemRenderer.  I need to do some formatting of my cells based on other row data. Here's what I mean... I have a datagrid and in row 0 col 2's itemRenderer I would like to access row 1 col 1's data in order to do a comparison so I can determine how to format row 0 col 2's data and so on.  Is there a way from within the item renderer to reach into another row and access the data?  I can't seem to find a clear answer so I thought I'd go to the pro's.
    Thanks!!

    You can use this code to get to the dataProvider of the grid.
    var o:Object = this.parent.parent;
    var dp:Object = o.dataProvider;

  • Purchase order document row is not change (document stutas is OPEN)

    Hi all,
    I am created one purchase order that are not any base or targeted document ,not any approval   procedure and  purchase order document status is steel open . Then how  I a cannot change the document row.
    thanks
    arabinda pal

    Hi Deepa,
    I think if you want to restrict the further editing of a particular row, then you just need to follow the simple procedure.
    1. create the purchase order with your desired items & vendor & add this document
    2. Now reopen it & goto that row which you want to restrict. Right click on that row & select "Close Row".
    3. Select yes to confirmation message.
    4.Now update the document.
    Now you an check it out, in that document you will not be able to edit that row contents.
    I hope this solves your issue.
    Regards.
    ShriX.

Maybe you are looking for

  • Is it really another error about full table scans for small tables....?????

    Hi , I have posted the following : Full Table Scans for small tables... in Oracle10g v.2 and the first post of Mr. Chris Antognini was that : "I'm sorry to say that the documentation is wrong! In fact when a full table scan is executed, and the block

  • Where to find .jar files so I can implement import java.util.logging

    I'm trying to figure out how to take an application built for Websphere and port it to WebLogic. I've come across this blog entry http://blogs.sun.com/fkieviet/entry/using_java.util.logging_in_bea_weblogic and would like to try creating and using the

  • USB gamepad recognized as a mouse

    I want to use my Logitech USB Gamepad to play some games, but when I plug it in it's not recognized as a gamepad but as a mouse. I can use the D-Pad or Joystick to move the mouse cursor and I can't figure out why that's happening. Here is a lsusb if

  • Cannot drop a Mapping !!!

    OMBCC is used to change context to Oracle Target Module When running OMBDROP MAPPING 'mapname' OMB+ generates PUB01010: Object is not deletable. Urgent. Please reply .. - Jojo Message was edited by: user467494

  • TestStand cannot distinguish between capital and small letters

    I've made an update from some Step Types that I've created in a computer into the TestStation. The name of all the files inside those Step Types are written in capital letters, but when I try to edit the Step Type under TestStand, this one tells me t