Really Quick Question
Really Quick Question
matt_rumsey1212
Posts: 51Questions: 8Answers: 0
in Editor
Is it possible in the newest version to dynamically change the ajax URL of editor...
for example: editor.ajax.url("/my/url/?query=" + myQuery).load()
This question has accepted answers - jump to:
This discussion has been closed.
Answers
I'm afraid not - no. You can change the DataTable data source URL, but changing the URL used by Editor via the API is not something that is currently available.
What is the use case for this? The reason it isn't available is that I couldn't think of any reason why it would be useful to be honest!
Allan
NOTE: The bottom comment shows the individual line that seems to be causing the problem; included the entire javascript for reference purposes or just if you are interested in how your hard work is being put to use :P.
I hindsight I may have gone about it the wrong way; its getting pretty complex to say the least... I'l try to explain and post my script.
So I have a page which when loaded displays 3 tables.
The first is a list of teams - Clicking on a team loads the second table which displays a list of members of said team (Works perfectly :)). Clicking on the team also opens a child row with a custom display controller for the editor (also works perfectly).
The third table is also animated to load at this point on the far right which displays a list of all agents (for adding members to the second table).
The second table - as mentioned above displays a list of team members and doesn't do a lot apart from display information. It does this by sending a query string back to the controller and then uses a where condition to show only the relevant agents.
The third table displays a complete list of all the agents. It only appears when a row is selected within the first table. It has a button with the action set to modify an editor fields value (the teams id) of selected rows in order to update the second table and display the updated members within it.
The problem occurs while I am trying to remove agents form the second table via a "Remove selected" button. I thought that this may be because I needed to set the ajax url to the same one as the datatable's one however in hindsight it may be because .val() is not updating the database when using: null, "NULL" or "" as entries.
it is on this section that the problem occurs:
I dont expect you to read through all the above. This is the line giving me grief. Submitting a null value doesn't seem to be possible.
All three of the above have not worked so far.
PS; Congratulations! Saw your post on the forum.
It sort of depends :-). Editor submits HTTP parameters which is just plain strings without any type information. So the issue is that there is no way to immediately distinguish between an empty string or
null
, or alternatively the string 'null' and an actualnull
!This is the one I would suggest and have the server see the empty string and take what action is needed based on that (deleting rows, or are you just marking them as removed?).
Allan
p.s. Thanks :-)
Team_id is just a foreign key value so no deletion or removal required at all. Literally just need to change it to null then reload the updated data set.
Will try out your suggestion now :)
No luck on this solution unfortunately
What does happen when you try the above? It should submit
Agent.Team_id
with an empty string to the server-side for the selected rows. Does that happen? What does the server-side do with that information (i.e. what code is being used)? Any errors?Allan
Aha; so further investigation into the chrome debugger shows this error:
"Conversion failed when converting from a character string to uniqueidentifier."
Are you using the Editor .NET libraries on the server-side? If so, are you using 1.5.3 (if not, can you update). If you aren't using the Editor libraries, you'd need to debug whatever code is being used on the server-side.
Allan
Managed to get everything working :) so...
It appears I needed to use the following within the controller to solve this issue:
Works like a charm now :).
The one final thing I need to solve is getting a 'null' option when selecting a team from an inline select box... Does there happen to be a built in way of achieving this?
Thankyou once again for your continued support and help throughout this process.
Good to hear you got that working.
I'm afraid I don't quite understand. What do you mean by "getting a 'null' option"? You want to provide an null option?
Allan
So the dropdown for selecting a team (In the editor popup or inline) when editing an Agent or creating an Agent always defaults to having a team selected as opposed to, say, being blank and allowing no team to be selected upon creation of an Agent.
Found your response to a similar problem in this:
https://datatables.net/forums/discussion/31257/select-dropdown-in-add-form-populated-from-database-does-not-have-a-blank-option#Comment_84355
Shall follow the accepted answer if this is still the best way of doing such a thing? :)
Yes, that's currently the way to do it. I'm thinking of adding a configuration option for it in Editor's built in select field type.
Allan
Awesome :), That would be a great addition!
May I ask what the C# equivalent of this would be please?
You can use:
to insert into a list in C#.
I'm not really much of a fan of this approach though, its messy. Let me look into what exactly will be required to add the option into the select field to add a placeholder and I'll try to include that in the next release (tomorrow) if all goes well.
Allan
Wasn't expecting that, awesome :)
I've just committed this in and it will be in 1.5.4. I'm not certain I'll get it out today now, but it will be in the next couple of days. its a nice little feature this I think though :-)
To add a placeholder option you can simply use the
placeholder
option. Typically this won't be selectable, but there are cases when you might want that (which it sounds like you might) - that is enabled using theplaceholderDisabled
option - so you might use:Allan
That is amazing! Thanks so much for providing this as an option. Is everything we needed and more!
Is 1.5.4 live yet out of interest?
No - sorry. For various reasons I wasn't able to get it out last week - it will be tomorrow (Tuesday 8th).
Allan
Placeholders for the select lists work perfectly dude! Thankyou :)
Good to hear - thanks!