-
Notifications
You must be signed in to change notification settings - Fork 147
Use aoColumnDefs to control visible and title of columns #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
danmiser
commented
Aug 2, 2012
- Resolves path name from DataTablesHelper.DataTablesInclude better
- Emit aoColumnDefs based on attributes of the view model
- Solves issue 12
- Solves issue 13
This change emits aoColumnDefs based on the view model that we are
rendering. For example:
1. [ScaffoldColumn(false) will apply bVisible: false to the column
2. [DisplayName("Title")] will apply sTitle: Title to the column
3. The sName property will always be set to allow for a more flexible
client and server side decoupling
I also changed the sample to demonstrate this, and clean up a few small
issues like making files look in the virtual path instead of an absolute
top-level path.
|
Hi Dan, thanks for this. I was just trying it out, and tried removing the [Scaffold(false)] from the Id parameter, and it still wouldn't display the Id column. Why might that be? |
|
According to this forum thread, you need to clear out your browser cache when changing between visible and invisible. The generated aoColumnDefs has the right values, but something is going on with the datatables code that is preventing it from updating visibility unless you clear out the cache. For me on Chrome, I had to "Empty the cache" and "Delete cookies and other site and plug-in data". You can see that it is cache related by opening up a different browser than you used before and the results are fine. http://datatables.net/forums/discussion/10860/can039t-seem-to-get-column-to-hide |
|
Weird. Looking at the file diffs in GitHub for Windows, I just saw the + and - on the appropriate lines. Looking at the diffs in this link, it looks like it completely lost the ability to determine which lines were changed. I hope that's a github bug and I'm not forcing more compare/merge work on you. My apologies if that is my fault. https://github.com/mcintyre321/mvc.jquery.datatables/pull/15/files |
|
It could be to do with line ending settings in your Git client differing On 2 August 2012 19:18, Dan Miser <
|
|
Do yo have any more info on why the cache needs to be cleared? This seems like a strange behavior, and one that may well cause a few (mistaken) support issues with Mvc.Jquery.Datatables. One other thing, I am wondering if we should have a [HiddenAttribute] rather than re-use Scaffold in a different context. Your thoughts? |
|
I'm checking in with Allan on that support thread. I gather he's the guy who wrote datatables, so it should be in good hands. I completely understand your concern on support, but this happens when using nothing but straight html and datatables as well. Let's see what Allan comes up with. At the very least, it should probably be documented prominently so you don't get swamped with emails. I'll comment back here once I get a response. As for [Hidden], I like it. But I'd really like to add that as an extra attribute instead of a replacement. The reason being, things like EditorTemplates and 3rd party components like Telerik use [ScaffoldColumn]. I think that dates back to the Dynamic Data days where scaffolding was being explored. So ScaffoldColumn and DisplayName are out there as first class citizens in the ASP.NET MVC world. |
|
The response from Allan, so not sure what to do next: |
|
Hi, Does the DisplayName attribute work? I gave it a try didn't see any changes, even after clearing out my browser cache. |
|
It worked on the sample that I modified for this change set. DisplayName does not require any cache clearing. That only appears to be needed for visibility changes. If it doesn't work in the included sample for you, let me know what browser version you're using. Thanks Sent from my iPhone On Aug 17, 2012, at 4:15 PM, senorcris notifications@github.com wrote:
|
|
Harry, Dan, any reason why this hasn't been merged yet? I'd like to expand on Dan's work to include other properties of aoColumnDefs such as mRender etc. PS I second the [Hidden] attribute. |
|
There is an outstanding issue which is that hidden columns remain hidden, even after you have removed the attribute. I don't want to add a feature that might cause support requests (i.e. headaches for me). OTOH, if it's just a bug in DataTables that will be fixed at some point, it's not my job to stop that feature being used... I've already accepted a different pull request for DisplayNameAttribute support also, so I think this fork will have to be synced with my master, and the DisplayName stuff undone before I can integrate it. Given that, I'm going to close this pull, and wait for another. |