2014-02-10 57 views
0

在我的jgGrid编辑表单中,我包含一个选择菜单。这些菜单是使用...jqGrid - 选择带特殊字符的菜单

'key:value;key:value;key:value' 

...字符串。我的值包含';'然后打破菜单。我的数据看起来像......

'key:some;data;key:more;data;key:even;more' 

另外,我的值还可能包含':'。

网格的autoencode在这里没有帮助。在交给电网之前,我可以preg_replace()。我还有什么方法可以解决我的问题?

非常感谢。

+0

我该如何逃避';'和';'字符在我的价值观或以其他方式导致jqGrid不窒息?感谢您的时间和反馈。 – user1801810

回答

0

在PHP构建字符串我做了以下...

... 

// 
// remove ';' and ':' 
// 
$value = preg_replace('/\:|\;/', '', $data['description']); 

// 
// turn other special chars into html entities 
// for easy removal below 
// 
$value = htmlentities($value, ENT_QUOTES); 

// 
// remove html entities 
// 
$value = preg_replace('/&#?(\d*?|\w*?);/', '', $value); 

... 

此时$值是干净的,可以附加到“键:值,键:值;关键......” jqGrid用来构建选择菜单的字符串。

这种方法工作得很好,很容易,但它牺牲了小部分信息在这里和那里,但在我的情况下,这是没有关系。

感谢您的阅读,希望这可以帮助您。