How can I dynamically update postData from a navigation button in jqGrid - jqgrid

I have a jqGrid with a custom navigation button that looks like this:
The button to the left of the refresh button is my custom button. I am successful in having it execute a $('#bom').trigger('reloadGrid'); but I need to know on the server which button initiated the request. I would like to add the button name to postData. I tried:
$("#bom").jqGrid({postData:{jqgAction:"release"}});
$("#bom").trigger('reloadGrid');
But that does not add the extra field to the request string. postData already has some values in it, and those are unaffected as I see them in the request. I just need to be able to dynamically add an additional field, and don't know how to insert the additional values.

I have found the answer. Instead of using:
$("#bom").jqGrid({postData:{jqgAction:"release"}});
to update postData, I can use:
this.p.postData.jqgAction="release";

Related

Url Button in Grid

I have a grid that shows a business component data. One field of this table is an Url type. I don't want to show the url as text, i want show only a button that, if pressed, opens the link.
How I can do that?
I found a solution for the problem:
I changed the visible property of the url field to 'false' and added the link to another field of the grid with this code in the 'load' event:
OtherFieldName.LinkTarget= '_BLANK'
OtherFieldName.Link = link(ATT:UrlFieldName)
I hope this can be useful for you.

Jqgrid - How to create a custom add-button that you can supply of parameters

When you create a jqgrid there is a default button on the bottom of the grid that allows you to create new records.
However, when you open the modal, all input fields are empty.
In my situation I need this button, but I also need the exact same thing but with the possibilty of adding a few parameters so some of the fields are already filled in. The parameters would come from the selected row at that moment.
Like when I click a row where the date is set to 01/01/2099 i need the add-modal to open with the date already set to that date.
You can use beforeShowForm or afterShowForm to make any changes in the Add Form during opening. For example you can read the values from currently selected row and fill some fields of the form with new values. To be open Add form on click or double-click on the row you need just call editGridRow inside of onSelectRow/ondblClickRow callback.

Issue with validation in knockout js

I put validation on name input field field you can see it when you click on addFields.I am having problem that validation message coming before click on Add Branch button because in addFields function i'm setting the value of name empty because if i don't do this click on edit and make changes and click add or cancel on it and after that click on addfields then it show the previous value in input fields. i want to show validation message on click of Add Branch and want input fields empty on click of addFields and with values on click of edit. How can i achieve these scenario together ?
here is link
`http://jsfiddle.net/sohimohit/43zkoszu/13/`
You can use showAllMessages(false) on your error object
http://jsfiddle.net/43zkoszu/16/
All though I must say that your method of doing this is a little strange. Normaly with MVVM you have a seperate model for this and create a new one each time you want to registger a new
As #Marius has already said, you need use isModifed(false) for changed field. So, your code should be like this
self.AddField = function(){
self.BranchId("");
self.BranchId.isModified(false);
self.name("");
self.name.isModified(false);
self.description("");
self.description.isModified(false);
// .... etc ..
self.show(false);
self.show.isModified(false);
self.showFields(true);
self.showFields.isModified(false);
}
Also, please, notice you have comas (,) instead of semicolons (;) in your AddField code.

How can I change my URL before loading my view?

I have a CodeIgniter webpage containing (i) a list of items and (ii) a form to add a new item or edit the details of a selected item.
To select an item for editing, I have an "edit" anchor tag with a hyperlink ending with ?id=nnn. This results in a GET request that populates the detail fields of my selected item and redisplays the list. My URL now contains site_address/index.php/country?id=151.
When I submit my changes the list is updated correctly but my URL remains unchanged. What do I need to do in my controller to remove "?id=151 after my update was successful?
Thanks for your help.
I'm not sure of everything you are doing, so I'll just answer directly:
in your controller, after you update, you can:
redirect('site_address/index.php/country');
Does that fit what you mean?
Through php there's no way to change URL after request expect redirecting
redirect('controller/method');
and you can success message using session flash message after redirecting, if that what makes you want to reload the view

displaying jqgrid in mvc3 after clicking on button

I'm building a simple mvc3 app using jqgrid.
My form currently calls a function in my controller that searches the database based on what the user has inputted into the textboxes after clicking on a search button.
I want to only display the jqgrid with the information after clicking on the search button.
Any idea on how to do this?
Thanks
You need to pass an additional variable to the controller to check whether you have selected a button or not.
example:
('#grid').jqgrid({
...
url: '/Controller/Action/?additionalvariable = ' + variable,
...
)};
where the value of the variable is true or false depending on whether you have searched or not.

Resources