Looking for the right way to configure datasource...

2 posts, 0 answers
  1. DB
    DB avatar
    5 posts
    Member since:
    May 2012

    Posted 20 Jul 2017 Link to this post

    I'm trying to find the best way to configure my radgrid to accomplish this scenario.

    Here is the scenario:

    (This all occurs within my Default.aspx page)

    1. A radtextbox control prompts the user to input the customer number.  The customer number is validated using data coming from a table adapter.

     

    2. I want to pass the customer number entered above into another query (table adapter) and return a item details dataset using it.  This is the dataset

    that I want my RadGrid connected to. 

    -------------------

    I have been able to figure out how to accomplish everything above by using the RadGrid (onneeddatasource) event. 

    Here is where my problem comes in:

    ---------------------

    3.  One of the columns in my item details dataset (column name PRINT) is a Boolean datatype.   I have set the PRINT column in my datatable associated with the table adapter to read-only = false.  I need to give the user ability to (check or un-check) that column in my RadGrid and have it update the datatable only.  I have no requirement to go back and update the SQL database with the updated datatable.   This data is going to be used to generate a sql report which is included in this project.  

    In summary, I haven't been able to find a way to query and store results in a local datatable and allow the radgrid to update that local datatable.  I've looked at the batch editing capability, but I don't like the way it requires having to press the save button in between paging.  I'd like to code it so that the user can click the check box and it immediately saves the result to the data table.  

    Is there anyone out there that can give me some advice or an example of how I can accomplish this problem?

     

  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    5425 posts

    Posted 25 Jul 2017 Link to this post

    Hi,

    I have just answered your support ticket with this question, and I am pasting my answer here for anyone else looking at a similar scenario:

    If you need to operate with a specific object in memory, I can suggest you do the following:

    • Retrieve this object and store it somewhere (Session, Cache, ViewState, a file, an SQL table that is not related to the main server/database, there are many options and the correct one depends on your data access layer and approaches).
    • Provide this object to the grid in its NeedDataSource event (you have already found this).
    • Perform the manual CRUD operations on your specific object with your own code. You can see examples of how to do that in the following demo: http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/manual-crud-operations/defaultcs.aspx.
      • Depending on the way you have this setup (especially if you use a template column with a custom checkbox), perhaps you could simply subscribe to its CheckedChanged event and perform the necessary operation there, then call the Rebind() method of the grid to update its data if that's necessary.
    • You can also find a similar example that stores the data table in the session in the following forum thread: http://www.telerik.com/forums/inserting-and-editing-data-when-using-a-in-memory-datatable. I must note that a data table is quite a heavy object and serializing it in the session or viewstate may cost system resources.

     

     

    Regards,

     

    Marin Bratanov
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top