Skip to content

Conversation

@danmiser
Copy link
Contributor

@danmiser 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.
@mcintyre321
Copy link
Owner

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?

@danmiser
Copy link
Contributor Author

danmiser commented Aug 2, 2012

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

@danmiser
Copy link
Contributor Author

danmiser commented Aug 2, 2012

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

@mcintyre321
Copy link
Owner

It could be to do with line ending settings in your Git client differing
from mine.

On 2 August 2012 19:18, Dan Miser <
reply@reply.github.com

wrote:

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


Reply to this email directly or view it on GitHub:

#15 (comment)

@mcintyre321
Copy link
Owner

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?

@danmiser
Copy link
Contributor Author

danmiser commented Aug 3, 2012

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.

@danmiser
Copy link
Contributor Author

danmiser commented Aug 3, 2012

The response from Allan, so not sure what to do next:
It shouldn't do - but your browser was caching an old version of the script for some reason, rather than reading the latest version. The browser should work that out automatically if the server is fully set up for caching, but it sounds like something went wrong there. Perhaps the browser is only refreshing certain files? I think you would need to look at exactly what the browser is doing to find out what is happening there.

@senorcris
Copy link

Hi,

Does the DisplayName attribute work? I gave it a try didn't see any changes, even after clearing out my browser cache.

@danmiser
Copy link
Contributor Author

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:

Hi,

Does the DisplayName attribute work? I gave it a try didn't see any changes, even after clearing out my browser cache.


Reply to this email directly or view it on GitHub.

@bcronje
Copy link

bcronje commented Oct 22, 2012

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.

@mcintyre321
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants