How can I customize a GridPanel column cell's content using server-side code? (OnDataBinding)

Page 1 of 2 12 LastLast
  1. #1

    How can I customize a GridPanel column cell's content using server-side code? (OnDataBinding)

    Hi guys, I have a gridpanel and there is a column that I implemented a custom renderer with a OnDataBinding event, how to implement a function that exposes the column value and content and allows me to read the current row values in order to customize this cell content?

    <ext:Column DataIndex="Printed" Header="Print" Width="50" >
       <Renderer OnDataBinding="RenderPrintColumn" AutoDataBind="true"/>
    </ext:Column>
    I need to read 3 different IDs from the SqlDataSource query that fills the GridPanel, stored on the <Reader> but not visible as columns in order to correctly place the cell's content.
    Thanks
    Last edited by geoffrey.mcgill; Jul 28, 2010 at 10:20 PM. Reason: please use [code] tags
  2. #2
    Hi paul-2011,

    Unfortunately I don't really understand what is required. Please provide more information re: the requirements.
    Geoffrey McGill
    Founder
  3. #3
    Quote Originally Posted by geoffrey.mcgill View Post
    Hi paul-2011,

    Unfortunately I don't really understand what is required. Please provide more information re: the requirements.
    Sure, the thing is, on this column I need to perform complex server side operations in order to decide what to render in there, so I will need access to a server side event when that cell is about to be data bounded and from there I will do the necessary operations, but in order to do do the operations I need to access not only the cell current value but the row ID as well, can you advise?
    Thanks
  4. #4
    Quote Originally Posted by paul-2011 View Post
    I will need access to a server side event when that cell is about to be data bounded and from there I will do the necessary operations
    no can do.

    This would need to be done client-side with a <Renderer> on the Column. The Renderer can perform logic based on the record value.

    If the value of a Data item is dependent on some server-side logic, that logic should be run server-side before the data is bound to the Store.

    Hope this helps.
    Geoffrey McGill
    Founder
  5. #5
    Quote Originally Posted by geoffrey.mcgill View Post
    no can do.

    This would need to be done client-side with a <Renderer> on the Column. The Renderer can perform logic based on the record value.

    If the value of a Data item is dependent on some server-side logic, that logic should be run server-side before the data is bound to the Store.

    Hope this helps.
    I understand but I'm looking for a simple functionality that standard ASP.NET controls always offered, I need to check the user's credential in order to render the cell with the correct values and add functionality or disable functionality, I can't do that on the client-side because of security issues, also, I'm binding the store to a SqlDataSource for speed, if I write the business logic when loading the data before binding to the store it will be slower, use more resources and generate more code to maintain, while with the "RowDataBound" event of most grid controls I can quickly enable or disabled functionality based on the user credentials and object ID, are you sure that there is no equivalente "RowDataBound" event for the GridPanel that can be run on server-side?
    Thanks

    Remember, I started like this:
    <ext:Column DataIndex="Printed" Header="Print" Width="50" >
       <Renderer OnDataBinding="RenderPrintColumn" AutoDataBind="true"/>
    </ext:Column>
    
    public void RenderPrintColumn(object sender, EventArgs e)
    {
      //how to query the cell value and row id from here and then change the cell contents?
    }
    Last edited by paul-2011; Jul 29, 2010 at 2:51 AM.
  6. #6
    No "simple" way to changing the cell during the row databinding event?
  7. #7
    Geoffrey, can you at least point me to the server side arguments that can be used on such Renderer OnDataBinding event in a manner that I could debug it myself and see what I can do? I'm currently using "object sender" and "EventArgs e". I think you understand what I'm trying to do, I just need to be able to create and remove controls inside a cell when it is about to be databound, server side.
    I appreciate if you could help me get over this.
    Paul

    <ext:Column DataIndex="Printed" Header="Print" Width="50" >
       <Renderer OnDataBinding="RenderPrintColumn" AutoDataBind="true"/>
    </ext:Column>
    public void RenderPrintColumn(object sender, EventArgs e)
    {
      //how to query the cell value and row id from here and then change the cell contents?
    }
  8. #8
    Hi paul-2011,

    I don't think the OnDataBinding event for the Renderer is going to help with your scenario.

    There's a fundamental difference with how old school ASP.NET controls (ie, <asp:GridView>) are handled compared to the Ext.NET data components (ie, GridPanel+Store). With ASP.NET, the creation of all html happens on the server, and then is sent to the client (browser). At times this package of bits being sent over the wire can be huge.

    With Ext.NET a small block of configuration script (JavaScript) is created on the server, then sent to client. The rendering logic and processing is done on the client. This distributes processing onto the client.

    There is no server-side "Row Binding" or "Row Render" event for the <ext:GridPanel>, because the GridPanel is rendered 100% in the client.

    If you need to modify the rendering of a GridPanel cell, you must implement with a <Renderer>, and/or <Editor> if editing data.

    If certain data should not be rendered in the client, then that data should not be sent to the client.

    If the <Renderer> is dependent on a profile value, the Renderer should be modified server-side before sending to the client.

    The <Renderer> is dependent on the Column and not specific to the Record/Cell. If each Record Cell can be handled differently, then the Renderer should handle this logic. The Renderer has full access to all values in the Record/Row.

    I did some investigation (ie, thinking), and it does appear we're missing a server-side Event which could come in handy... especially when dealing with DataSource data. We're missing an OnRecordBound server-side event for the Store.

    The OnRecordBound server-side Store event would be fired for each record and enable a developer hook into the record values so each record could be modified before the data is sent to client. This would enable running profile specific logic against the Data.

    This OnRecordBound Event would only deal with the Data (Record), not the presentation or rendering of the data items.

    I apologise for the stream of consciousness above.

    You might have a scenario where all this just doesn't fulfill your requirements, so I'll need more information. I need a better/detailed description of your scenario. Screen capture or mockup would help. If you do not want to post this information in a public forum, please email me directly at geoff@object.net.

    Hope this helps.
    Last edited by geoffrey.mcgill; Aug 04, 2010 at 9:24 PM.
    Geoffrey McGill
    Founder
  9. #9
    I should mention, we're in the process of implementing the OnRecordBound event. We need to make some changes, so it's not the simplest feature to add, but shouldn't take too long either.
    Geoffrey McGill
    Founder
  10. #10
    Quote Originally Posted by geoffrey.mcgill View Post
    I should mention, we're in the process of implementing the OnRecordBound event. We need to make some changes, so it's not the simplest feature to add, but shouldn't take too long either.
    Geoffrey, thank you so much for taking some time to explain it to me and I'm glad to hear that you guys are working on something similar to the functionality that I was looking for, perhaps I have created a bad database design or I was trying to create an even worse presentation logic, I will do some brainstorming on this.
    Thanks again,
    Paul
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 0
    Last Post: May 10, 2012, 12:38 PM
  2. [CLOSED] Center GridPanel cell column content
    By deejayns in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Apr 04, 2012, 10:24 AM
  3. Replies: 0
    Last Post: Jun 21, 2011, 2:51 AM
  4. Replies: 2
    Last Post: Apr 26, 2011, 6:50 PM
  5. GridPanel Cell Value at Server Side
    By Ganesh3.shirsath in forum 1.x Help
    Replies: 1
    Last Post: Sep 29, 2010, 3:01 PM

Posting Permissions