Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
3160
Hosting user control in grid
posted

Desired behaviors:

  • User must be able to click on a field and just start typing (not need to press f2).
  • When account number is selected, account name is populated and focus moves to account name.
  • When account name is selcted account number is populated and focus moves to quantity.
  • When user tabs out of quantity field, row changes should be updated to ItemsSource.
  • When row changes are saved, focus should move to account number field on the "Add Row".  So, when the user adds a new row, and tabs out of the qty field, the row should be added to the grid and the cursor should move back to the account number field of the "Add Row" .

In the attached project, grid2 (the lower grid) does almost all of the above.  There are a couple of problems however:
1.) if the user inputs an account number or name but not a quantity, the update method is not called.  I beleive this is because Acct No/Name columns do not cause a DataItem to be generated when their values change.  Since there is no editor, how do I accomplish this?
2.) the grid alwayus apppears to be in edit mode.... note the visual differences vs. grid1.


grid1 in the attached project is related to the question I asked here: http://ko.infragistics.com/community/forums/p/79192/400321.aspx#400321
This grid is visually correct however I am unable to figure how how to access the controls in each row such that I can populate data values, set focus, etc.


I really dont care how the above desired behaviors are achieved I just need this to work.  What ever is fastest, easiest, and the least amount of code is fine with me.

SamsControls.dll exists in the Lib directory.


Thanks for your help.


 

XamGridEditorTest.zip
Parents
  • 30945
    Verified Answer
    Offline posted

    Hello Sam,

    Thank you for your post. I have been looking into the functionality that you are trying to achieve and regarding the list of requirements that you have provided, here is how you can implement them:

     

    1. User must be able to click on a field and just start typing (not need to press f2).
    • You can use the PreviewKeyDown event of the XamDataGird. There, you can check whether there is cell, which is currently active and if so, you can call the ExecuteCommand method of the XamDataGrid, with DataPresenterCommands.StartEditMode command, which will put the currently active cell in edit mode.
    1. When account number is selected, account name is populated and focus moves to account name.
    • For this, you can use the SelectionChanged event of your custom SelectorTextBox control. In the event handler, you can use the ActiveCell property of the XamDataGrid to get the name of the field and if the field is “ACCT_NO”, you can set the ActiveCell to the “ACCT_Name” cell of the same record and call the same command as for 1.
    1. When account name is selcted account number is populated and focus moves to quantity.
    • You can use the same approach as 2. and check the name of the field of the ActiveCell and it is “ACCT_Name”, you can activate the “QTY” cell and call the command form 1.
    1. When user tabs out of quantity field, row changes should be updated to ItemsSource.
    • When you are changing a value of some of the cells and exit edit mode of that cell the data object, corresponding to the record is automatically updated form the XamDataGrid. For the AddNewRecord, the first time, you change the value of the editor of one of the cells, an item is created and added to the data source and also the changes are applied to the data item of the record.
    1. When row changes are saved, focus should move to account number field on the "Add Row". So, when the user adds a new row, and tabs out of the qty field, the row should be added to the grid and the cursor should move back to the account number field of the "Add Row" .
    • You can use the RecordUpdating event of the XamDataGrid, in order to implement this functionality. You can add a check into the event handler, for checking whether the record is AddNewRecord and also if the Tab key down and if this is true, you can activate the first cell of the AddNewRecord and call the StartEditMode command.

     

    Regarding the first issues that you have described, I assume that by update method, you are referring to the RecordUpdated event. The event is not firing for the AddNewRecord and it seems that the reason for that is, as you have mentioned, that you are not using editors in the XamDataGrid at the bottom.  The reason for that is, that the new record is added to the data source of the XamDataGrid, when you edit a value of one of the editors of the add new record. Since you are not having an editor, the XamDataGrid is not adding an item into the DataSource, until you type a value into the “QTY” field. What I can suggest is using your SelectorTextBox as in the XamDataGrid at the top of the window. Using an editor allows you to have default feature of the XamDataGrid and also to have better appearance. Regarding the second issue that you have described, the reason for the appearance that you are having, is that you are not having editor in the template of the CellValuePresneter. As I have mentioned, you can use the ValueEditor that you have created in order to be able to control the appearance of the cells in both edit and non-edit mode. I have modified the sample application that you have attached in order to implement the above changes.

     

    Please let me know if you need any further assistance on the matter.

     

    Sincerely,

    Krasimir

    Developer Support Engineer

    Infragistics

    www.infragistics.com/support

    XamGridEditorTest_1.zip
Reply Children