Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
3.4 Beta 2 - jqGridImport
30/01/2009
22:35
Avatar
daveyoi
daveyoi
Member
Members
Forum Posts: 8
Member Since:
18/12/2008
sp_UserOfflineSmall Offline

Hello

I am currently migrating my js based dynamic column code to use the newly implemented jqGridImport as in 3.4.

Is it possible to pass or attach an event handler?  I have some code I want to execute after the grid is complete so thought to use the following:

loadComplete : function()

{

   // resize table width and other tidy actions

}

The problem is if I pass this as a string in JSON then it does not get evaluated as code..

Is it possible to use events using jqGridImport?

Cheers

Dave

31/01/2009
05:12
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

I think you should experiment in reverse order.

1. Construct your grid standart way including events

2. Make export of the grid using the method jqGridExport using the options jsonstring.

This way you can see how to configure the events in the jsonstring.

Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

31/01/2009
11:48
Avatar
daveyoi
daveyoi
Member
Members
Forum Posts: 8
Member Since:
18/12/2008
sp_UserOfflineSmall Offline

Hey Tony,

Thanks for your reply.. I had the same thought after posting on here.. and the jsonstring is displayed as I thought..

“loadComplete” : function () { ///blahblah; },  (notice the lack of quotes around the function).

The problem I am having is recreating that in PHP.. 

This doesnt work

$output->grid->url = “dyntab.php?action=data”;

$output->grid->loadComplete = “function() { \\\\\\ blahblah;  }”;

And this wont compile in PHP (obviously.)

$output->grid->url = “dyntab.php?action=data”;

$output->grid->loadComplete  = function() { \\\\\\ blahblah; };

Im not sure if there is a way to store a function in an object to be then encoded in JSON.?

The main reason I need this to happen is because I would like to fix the bug where if you add columns dynamically the total grid width grows by 7px for each column rather than keeping the width as specified in the configuration. Maybe there is another way then callng setGridWidth after creation?

Thanks

Dave

03/02/2009
01:09
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

I think this is reasonable. The grid eval the string and there is no other way to determine if this is a function. If it is a quted it is interpreted as string. Any idea on how to resolve this will be helpful. Also it is easy when we use xml - in this case the function is enloased in CDATA.

Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

03/02/2009
08:00
Avatar
daveyoi
daveyoi
Member
Members
Forum Posts: 8
Member Since:
18/12/2008
sp_UserOfflineSmall Offline

Tony,

Good call on the [CDATA] tags - I did some research for a PHP/JSON equivalent and the awnser, it seems, is PHP 5.3 and NOWDOC.

$complete_function = <<<'EOT'

function() { dosomething(); }

EOT;

$export->grid->gridComplete = $complete_function;

Unfortunatley no 5.3 is still in Beta and not suitable for my production server. So I have a grid workaround.

I edited grid.import.js and made your $.ajax() call non async - this way I can then use .setGridWidth to correct the grid dimensions. 

Thanks for your help Tony - I will take a copy of PHP 5.3 Beta down later and test the above to enure that it works.

Dave

03/02/2009
12:42
Avatar
FredyC
Member
Members
Forum Posts: 17
Member Since:
02/02/2009
sp_UserOfflineSmall Offline

Well, you always have an option to write your own json writer, which will build json string with your rules. When you look at english online manual, in comments to function json_encode, there are already some nice looking replacements, which you can eventualy extend for your needs. This core function is for simple types only with no extensibility.

I was solving this problem just today in my asp.net application, it was really easy.

16/04/2009
12:54
Avatar
jeff
Member
Members
Forum Posts: 5
Member Since:
16/04/2009
sp_UserOfflineSmall Offline

I know this topic is a bit older, but I was having the same problem with json_encode and javascript functions. After a little searching, I found this solution:

http://solutoire.com/2008/06/1.....over-json/

Very simple to implement and it works great!

--jeff

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
81 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information