Thanks Tony,
Adding key=true to the idx column has fixed the rowid issue out 🙂
However the afterInsertRow still fires for each row when the grid is sorted – is there a way to prevent that? It's not urgent as I can just test within that function whether the rowid is >= to the length of the array I'm filling the grid from – if it is then it's a new row … if not then it's already there – but it would be nice if that it didn't fire at all on sorting. I suspect there must be a good reason for this happening though so testing is probably the route I should take.
Thanks again
Romyn
ps. Using version 3.5 as I haven't yet had the time to upgrade – I did a quick test of my full site on 3.6.4 but got some errors so need to work through those at some stage.
Hi,
Lose the , at the end of the caption line.
caption:”Mon premier exemple”,
should be
caption:”Mon premier exemple”
That's the obvious one – don't know if there are more.
Regards
Romyn
Hi,
While I'm not Tony I'm pretty sure he'd tell you to read the docs
– and as I ask a few questions it's only right that I try and answer one every now and then when I can.
The answer is yes you can and there is a good example on the demo pages
http://trirand.com/jqgrid/jqgrid.html
Goto New in Version 3.3 and select the Cell Editing example.
That demo shows the use of cell editing and the afterSaveCell() method. When a value in the Amount or Tax columns are changed the afterSaveCell call then updates the Total column with a new calculated amount using setRowData.
That's the principle you're after I believe.
Hope that helps
Regards
Romyn
Hi,
You can do it using setCaption but to get it to lineup on the right next to minimise you'd need to either use a number of ' 's or maybe it can be lined up using css? If you allow your grid to be resized then that's another thing you would have to handle in some way.
$(“#mygrid”).setCaption('My Caption ' + '');
… adds an image button a few spaces after the text 'My Caption' for example.
Hope that helps.
Romyn
That's a good question which unfortunately I don't know the answer.
I just copied one of the examples and changed the Select to point to my table structure. I don't know why it's doing what it's doing and I'll have to look into it and hopefully find a permanent solution.
In the meantime I've amended the PHP by adding near the beginning…
if ($page == 0) {
Hi,
I get that – and that's the problem I'm trying to solve.
I don't know what I'm doing that causes the grid to ask for page 0.Why is page 0 in my Headers and thereofre in the Response?
Put it another way – if I wanted to open the grid on page 5 what would I need to do.
Thanks
Romyn
Sorry – don't quite understand what you mean with that “trick”.
The first call sends the Headers:-
_search false
nd … (a long number)
page 0
rows 10
sidx place_overall
sord asc
Response begins with (up to start of 2nd record):-
|
1 |
{"page":"0","total":2,"records":"20","rows":[{"id":"19948","cell":["19948","1","8","Keflezighi","Meb"</code><code>,"M","34","02:09:14"]},{"id":.........<br /><br />With that I get the funny records numbers.<br />After a sort the Headers and Response are the same except<br /> |
Headers has:- page 1
Response has:- {"page":"1" ........
Not sure if that helps at all?
Romyn
Thanks Tony,
With 1 & 3 I was looking in the wrong place – fixed now – your fault for making jqGrid so comprehensive 😉
Your suggestion for 2 works a treat 🙂
As for number 4 … what seems to be happening is when the grid initially loads the header sent to the url.php is asking for page=0 and the records say “-9 to 0” when returned – although the grid contains records 1-10. As soon as I do a sort or reset then next call is correct for page=1.
I can't see what I'm doing to cause this to happen. The only thing slightly different about the grid is that when I initially set it up I give it a dummy url which I then change using setGridParam and then use trigger(“reloadGrid”) to fill it.
This is the grid:-
Thanks for that Tony,
Got the ui-dialog working ok – bit fiddly getting the position correct but got there in the end. Only need to get the buttons looking similar now but I'm sure I'll get there.
Cheers and regards
Romyn
Thanks.
I've now managed to get the select's listing to work but have run into other problems now.
I initialise the relevant column in the grid with
{name:'dbcourseid', index:'dbcourseid', width:60, editable:true, edittype:'select', align:'left'}
I then work out what the courselist should be – in this case
19:Blue;20:Orange;21:Green
I then set this as the source for the column using
$(“#grid_rm”).setColProp('dbcourseid',{editoptions:{value:courselist}});
I then load 2 rows using addRowData
The dbcourseid column for these 2 rows show the numbers rather than the colours. I've tried with formatter:'select' but that doesn't seem to work either. (I'm running an earlier version of 3.5 so upgraded to 3.5.3 but that causes other errors in other grids which I can't pin down)
However if I add another row using editGridRow(“new”) then the dropdown in that shows the colours and also stores the colour, rather than the number, in the grid.
I can't work out what I have to do to make the column behave like a standard foreign key column – ie ID Value where the ID is stored but the Value is displayed. I suspect this may be fixed, from reading other threads, on the latest version but I can't get 3.5.3 to work without errors elsewhere and when I skip over the bits that it errors on (other grids) it still doesn't do it – with or without the formatter option set.
Am I doing something fundementally wrong here?
Thanks again.
Romyn
edit: – cancel that- just started working again?
I'll admit to being pretty confused myself now.
I've downloaded the latest GitHub files and made the changes to how the functions are defined – (don't know where the var versions came from – must have been done that way in the examples I used).
Anyway with those changes made I'm still having some trouble. The ideal scenario I want to get to is to store as Seconds, display as HH:MM:SS and edit using a Mask in the for __:__:__
To that end I've put together a simple page with a grid that has various differently configured columns – and celleditting enabled so just clicking in and out of the cell should show the effects.
http://www.thekmz.co.uk/GEPlugin/wip/test/gridtest4/gridtest4.htm
Simple – no formatting at all
fmt – just the formatter
fmt/unfmt – formatter and unformatter
fmt/mask – formatter and mask
fmt/unfmt/mask – formatter, unformatter and mask
The fmt/unfmt column works as designed (except when the value is 0 which I can't suss out?) – but I want to then add the mask to that but that doesn't seem to work. I also appreciate that some of the columns shouldn't work correctly but they are there just to show how I build up through adding the various options)
(also tried the var myval = $(cellval).html(); thing you mentioned but that didn't work for me at all so I went back to the old style).
Sorry this is so confused but it reflects the state of my little brain…
(I might be better off going back to storing the value as a HH:MM:SS string but I want to avoid that if I can)
Regards
Romyn
I've just downloaded the latest pack again (not the GitHub one) and it is different so I'm not completely up-to-date on that by the looks of things.
However using the latest a TreeGrid I have gets stuck on “Loading” so something has changed in that that I need to fix first – new syntax or something?
I'll try and do that and then see if the unformat function gets called. (Can't get to it until I fix the TreeGrid as that is the launch point for the other grids with the meat in them)
Regards
Romyn
edit – just seen your other reply. Thx – I'll download again in a few days.
Hi,
The relevant bits are:-
The col model:
{name:'sdelay', index:'sdelay', width:60, align:'center',editable:true, editoptions:{dataInit:function(el){$(el).mask(”99:99:99″);}, defaultValue:'00:00:00'}, formatter: fmt_HMS, unformat: unfmt_HMS},
The format function:
var fmt_HMS = function(cellval,options,rowdata) {
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top