Skip to content
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

Proposal for improving feature - Dynamic values for "select" formatter #1049

Open
unle70 opened this issue Oct 29, 2023 · 5 comments
Open

Proposal for improving feature - Dynamic values for "select" formatter #1049

unle70 opened this issue Oct 29, 2023 · 5 comments

Comments

@unle70
Copy link

unle70 commented Oct 29, 2023

Hi Tony,

When using the "select" formatter, the documentation is giving a quick hint that the editoptions.value (and formatoptions.value) can actually be a function.
I see that indeed you can define a function there, for dynamically setting the select options, but there's a problem. This function is getting NO input parameters and "this" is pointing to some internal jqGrid object (not a DOM element).

I think it would be very nice if this function could have some useful parameters, maybe the same as for the custom formatter, and "this" should point to the grid. It would make things easier when implementing dynamic values.

@tonytomov
Copy link
Owner

Hello Udi,

Thanks for the recommendation.

I think we can pass the grid element (this) and the options (which contain everything you need).

I will refer this issue when these are added.

Thank you
Tony

tonytomov added a commit that referenced this issue Oct 30, 2023
@tonytomov
Copy link
Owner

You can test the new addition as described into the commit.

@unle70
Copy link
Author

unle70 commented Nov 3, 2023

Hi Tony,

Well, for having a "full solution", there are 3 places that need to be handled:

  1. Editing - editoptions.value - You have handled
  2. Formatting - When using type 'select', this formatter will try formatoptions.value and if not found, will use editoptions.value - This was not yet handled
  3. Filtering - searchoptions.value needs to be handled. I believe the same logic should apply as in formatting. If searchoptions.value is not found, need to default to formatoptions.value or editoptions.value. - This was not yet handled.

#1 looks OK at this time, but in my case I cannot use it without have #2 and #3 working as well.

@tonytomov
Copy link
Owner

The select as function can be used in editoptions and searchoptions.
This is true since the select as function is defined in createEl function which is called every time when input select element is created including in searching methods.

Not sure that the logic you describe should be applied, instead that historically in certain places it is available.
I think that every module (formatter, edit, search) should have his own options and not use the option from the other when it is not defined.

@unle70
Copy link
Author

unle70 commented Nov 9, 2023

Hi Tony,

When I tried to use the "function" type "value" for the "select" type in formatting, it didn't call the function. I looked at the code and didn't see any checking for type "function" there (I think it's in "jquery.fmatter.js" line 234 and on). I only see checking whether it is a String or an Object. Am I wrong about this location?

As for the different options, I understand your point. It's just that I saw the code mentioned above, and saw that it DOES have this fallback from formatoptions to editoptions (line #242). So that is why I was proposing the same line of thinking for searchoptions. But it's OK if you keep them separate.

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

No branches or pull requests

2 participants