none
Can I suppress a dataview row filter update RRS feed

  • Question

  • I am using a datagridview bound to a dataview with a row filter to find rows that have no value in a specific column.  Then I have buttons to put a value in there... But as soon as I put a value in, the updates the dataview removing the row.  What I really want is for it to leave the edited rows there until I hit a committ button... that would triger an update to the database, then the dataset, then the dataview and finally the datagridview.  Any ideas on how to do this?

    Randell
    Friday, May 29, 2009 9:00 PM

Answers

  • I can agree the extra fields will work, but I can't see how that is less complicated then disabling the update temporarily, if that ability existed...
    However since no one seems to know how to do it, I have to assume it simply inst' possible to disable the update in any normal fashion... I imagine one could override a specific method of the datatview to not update based on a flag or something, but that is clearly no practical...
    So unless someone knows of a way, the answer to the question - "Can I suppress a dataview row filter update" is no.

    Randell
    • Marked as answer by RandellP Monday, June 1, 2009 4:56 PM
    Monday, June 1, 2009 4:56 PM

All replies

  • mmm, usually you need to submit or discard change before you refresh. Ask the user to confirm.
    as for filtering, display the search result in a new grid would help.

    MSMVP VC++
    Friday, May 29, 2009 9:15 PM
  • Yeah I thought this was a normal concept... so I must be doing something wrong if the view keeps updating at the  slightest change... I even tried having the user edit the column manually.  As soon as they move to a new row, the row they edited disappears because now it has data in that column.  So something is telling the view to update on the fly. 
    On the display the search result in a new grid, I don't follow what you mean...

    Randell
    Friday, May 29, 2009 9:56 PM
  • What is the exact expression you are using for the RowFilter property?

    Thanks
    Chris Robinson
    Program Manager - DataSet


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Friday, May 29, 2009 10:03 PM
  • well I did simplify a tiny for my above example... I am actually looking for rows where the column isn't "assigned"
    dataViewNewBugs.RowFilter = "tag NOT LIKE '%assigned%'";

    If you put text other then assigned in there, nothing happens... but as soon as you put the text assigned in the tag column the row disappears.  I have managed just recently to stop it from disappearing in the case where I have code setting the value... I did this by using a row.beginedit, and not doing an endEdit.  But of course then the change doesn't show up in the gridview so that is pointless, and really just a poor hack anyway.

    Randell
    Friday, May 29, 2009 10:14 PM
  • Hey Randell,

    The reason its filtering this way is because of the design that you have. The filter that you have here says to me that any row where the tag is not Like assigned. So the row will filter anything that contains 'assigned' in it. Its doing exactly what you expressed it to do.

    http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx

    Above is a link about how the expression language works.

    I would write a simpler program and get the expressions correct, if you want have a button that toggles between the different rowfilters, that way you can see what kind of difference they make.

    So if you want to exclude rows which don't have assigned in them just remove the NOT from your expression.

    Thanks
    Chris
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Friday, May 29, 2009 11:18 PM
  • Okay, so maybe some more background is needed.  I have a dataset with lots of stuff in it from a large qurey to a database.  In "state A" I want my datagridview to show all tickets that don't have assigned in the tag field.  Then the user will select a row, and click a button next to the datagridview to assign the active row to a person... the code will change a different column, and will put the word assigned into the tag column.  But it will not commit the changes to the database just yet.  So this leads to "state B".  In state B I want the datagrdiview to show anything that doens't have assigned in the tag column, and I want it to display anything that was assigned by this tool when the user hit a button to assign the row to someone.  Then to get to "state C" the user would hit a commit button which would commit the changes to the data base and refresh the datagridview to show only tickets that currently don't have assigned in the tag field.
    My problem is with state B.  I can't get the datagridview to continue to show the items that were recently assigned.  I can't think of anything I could change the filter to that would get me the items that have recently been assigned, without giving me eveything in history that was ever assigned.  And I don't want that.  In theory to make it do this, I would need to stop the dataview from re-evaluating the filter, and leave the rows as they are, but with any changes made by the user until the user hit committ, at which time I woudl turn back on the row filtering or updating or whatever.
    So as far as I can tell there is nothing I can do to the filter to fix this... I need to actually stop the update until the user hits the commit button.  One solution I have recently come up with is I could actually make a snap shot of the portion of the data set I want to work with, and tie that to the datagridview.  Then when the committ button is hit, sync tha back to the main dataset, and committ that set to the database.  But this seems horribly ineffienect as it means there will be two copies of the data floating around that could get out of sync and have conflicts...  Thus i am persuing the angle of supressing the update from happening while the user is editing...

    Randell

    Friday, May 29, 2009 11:53 PM
  • Hey Randell,

    I think your overcomplicating this a bit. I don't know exactly your schema, but what if you had a field that had LastAssignedDate, then your filter query for state B would simply be any rows where the DateTime is within a particular date range. Perhaps you already have some history that you can use, I'm not sure. I think you need to think about based on the data you have stored how can you write a filter query to to ones that were assigned recently. That's my only suggestion.

    Thanks
    Chris
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Saturday, May 30, 2009 12:20 AM
  • I could manufacture a field for use.. but I don't own the db, so it would only exist in the dataset in my program.  Since in "state b" I haven't committed to the db, none of the database fields will matter, as they won't have been updated yet.  The theory is I am trying to replicate the behavior I would get if I could hook a datagridview directly to a dataset, where you make changes but that doesn't effect the rows you see until you committ them.  Which of course is the other way I mentioned, making a copy of the dataset to work with, and taking the view out of the picture.  I guess I could also manually populate the view, and not use a row filter at all.  It just seemed like there should be a way to stop the rowfilter from modifing the dataview, and work with just the snapshot for a period of time...  But since no one seems to know of one, I guess there isn't...

    Randell
    Saturday, May 30, 2009 1:03 AM
  • I think that in this case creating another field or another Datatable even just for your application might be the best thing. You could always just create another table that has a relation to the table. You could use the eventing infrastructure on RowChanged to monitor the  tag column. Then whenever it changes add this change to another table. This table can just be thrown away, no need to save it. It could be used to identify state B. I would look at this way. Then for the filter you can do some type of expression for state B. The other approaches you are taken seem overly complicated in my opinion.

    Thanks
    Chris
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Saturday, May 30, 2009 10:30 PM
  • I can agree the extra fields will work, but I can't see how that is less complicated then disabling the update temporarily, if that ability existed...
    However since no one seems to know how to do it, I have to assume it simply inst' possible to disable the update in any normal fashion... I imagine one could override a specific method of the datatview to not update based on a flag or something, but that is clearly no practical...
    So unless someone knows of a way, the answer to the question - "Can I suppress a dataview row filter update" is no.

    Randell
    • Marked as answer by RandellP Monday, June 1, 2009 4:56 PM
    Monday, June 1, 2009 4:56 PM