讓 YUI DataTable 使用 JSON Data Over XHR 時支援中文 field

原由

YUI 真是個好東西,最近拿它來寫公司的程式。
天殺的! 不知以前是誰把資料庫欄位都用中文命名。
我輸出 JSON 長這樣...


{
 "ResultSet": {
  "Result": [{
   "ID": "1234",
   "姓名": "林洵賢",
   "電話": "1234567890"

... 省略

話說當今瀏覽器 UTF8 編碼的頁面 JavaScript 運作起來是沒什麼問題。
但 YUI 是外國人設計的,用它的 DataSource 抓資料後認為這些以中文為 key 的是壞東西會自動被忽略。


解決

追程式囉! 我原本是用 DataTable 當然從它開始追,追到另一個模組 DataSource 找到了!
我用的是 YUI 2.9 版,修改 \build\datasource\datasource*.js 原始程式,把

[^\w\.\$@]

改成

[^\w\.\$@\u4e00-\u9fa5]

就支援中文 key 了。


或許這篇算是寫給自己的筆記,沒接觸過的應該看沒有。
如果你不幸也在找同樣的解決方案 google 到我,那恭喜你囉,留個言吧!


後記
後來發現欄位排序中文Key也有問題,要修改 datatable*.js 尋找 [^\w\-] 改為 [^\w\-\u4e00-\u9fa5] 即可。

30 個回應:

chenmeinv0 提到...

north face jackets
moncler coats
fitflop shoes
ugg outlet
ray ban outlet
canada goose sale
nike tn pas cher
michael kors outlet
oakley sunglasses outlet
pandora jewelry
2016.10.27xukaimin

chenlina 提到...

ralph lauren
oakley sunglasses canada
north face jackets
ugg boots
ray ban wayfarer
cheap basketball shoes
nike air max
cheap mlb jerseys
coach outlet
nike roshe run
chenlina20170109

chenlina 提到...

coach outlet
oakley sunglasses wholesale
ralph lauren uk
louis vuitton outlet online
gucci shoes
michael jordan shoes
clarks shoes
polo ralph lauren
rolex datejust
hermes uk
chenlina20170720

Unknown 提到...


Furniture move
he majority of DIY home movers are really interesteD in knowing how to properly loaD their renteD moving vehicles so that the entire storage spACe is utilizeD in the Best possiBle way. نقل عفش بالرياض The main concern for families who have DeciDeD to move on their own still remains the Danger of choosing a moving truck with insufficient spACe for their Belongings. شركة شراء اثاث مستعمل بالرياض To complicate things further, even the right choice of a rental moving vehicle can easily turn out to Be a serious proBlem if the loaDing process is not Done the right way.افضل شركة نقل عفش بينبع AnD Believe us, leaving prizeD possessions BehinD or Being forceD to make two trips are two moving scenarios you Don’t really want to go through for various reasons.شركة نقل اثاث بجدة - افضل شركة نقل عفش بالمدينة المنورة
EveryBoDy knows that when given at the right time, gooD moving aDvice can mean the worlD to stresseD home movers, anD will prove to Be the Difference Between a successful house move anD a Disastrous proBlem-filleD relocation. افضل شركة تخزين اثاث بالرياض This is why, having alreaDy DescriBeD in Details the truck loaDing process anD the way to overcome its challenges, it’s only fair that we say a few worDs aBout how to unloaD a moving truck once you have reACheD your Destination.

klinik aborsi jakarta 提到...

Klinik Aborsi Jakarta
Klinik Aborsi Raden Saleh
Klinik Kuret Jakarta
Klinik Kuret
Klinik Raden Saleh
Klinik Aborsi Aman
Klinik Aborsi
Klinik Aborsi Legal
Biaya Aborsi

Anonymous 提到...

Now, if you are the registered employee or an authorized associate working for one of the largest banking institutions in the country and want to access Bank of America Employee Benefits info or register at BofA Resources At Home website then get easy instructions shown below now. 메이저사이트

Anonymous 提到...

Now, if you are the registered employee or an authorized associate working for one of the largest banking institutions in the country and want to access Bank of America Employee Benefits info or register at BofA Resources 스포츠사이트

Anonymous 提到...

if you are the registered employee or an authorized associate working for one of the largest banking institutions in the country and want to access Bank of America Employee Benefits info or register 사설토토

Anonymous 提到...

employee or an authorized associate working for one of the largest banking institutions in the country and want to access Bank of America Employee Benefits info 먹튀검증사이트

Anonymous 提到...

authorized associate working for one of the largest banking institutions in the country and want to access Bank of America Employee Benefits 안전놀이터

Anonymous 提到...

Now, if you are the registered employee or an authorized associate working for one of the largest banking institutions in the country and want to access Bank of America Employee 토토사이트

Anonymous 提到...

if you are the registered employee or an authorized associate working for one of the largest banking institutions in the country and want to access Bank of America Employee Benefits info or register 먹튀폴리스

Anonymous 提到...

It is great to have visited your website. Thanks for sharing useful information. And also visit my website about health. God willing it will be useful too 스포츠사이트

Anonymous 提到...

if you are the registered employee or an authorized associate working for one of the largest banking institutions in the country and want to access Bank of America Employee Benefits 메이저사이트

Anonymous 提到...

employee or an authorized associate working for one of the largest 먹튀검증

온라인카지노사이트 提到...

온라인카지노사이트 Hello! This is my first visit to your blog! We are a group of volunteers and starting a
new initiative in a community in the same niche. Your blog provided us
valuable information to work on. You have done a marvellous
job!

토토365프로 提到...

토토 I have read your blog and I gathered some new information through your blog. Thanks for sharing the information

메이저사이트 목록 提到...

메이저사이트 Hi, just wanted to say, I loved this post. It was practical. Keep on posting!

匿名 提到...

youtube abone satın al /n trendyol indirim kodu
cami avizesi
cami avizeleri
avize cami
no deposit bonus forex 2021
takipçi satın al
takipçi satın al
takipçi satın al
takipcialdim.com/tiktok-takipci-satin-al/
instagram beğeni satın al
instagram beğeni satın al
btcturk
tiktok izlenme satın al
sms onay
youtube izlenme satın al
no deposit bonus forex 2021
tiktok jeton hilesi
tiktok beğeni satın al
binance
takipçi satın al
uc satın al
sms onay
sms onay
tiktok takipçi satın al
tiktok beğeni satın al
twitter takipçi satın al
trend topic satın al
youtube abone satın al
instagram beğeni satın al
tiktok beğeni satın al
twitter takipçi satın al
trend topic satın al
youtube abone satın al
takipcialdim.com/instagram-begeni-satin-al/
perde modelleri
instagram takipçi satın al
instagram takipçi satın al
takipçi satın al
instagram takipçi satın al
betboo
marsbahis
sultanbet

Unknown 提到...

beğeni satın al
instagram takipçi satın al
ucuz takipçi
takipçi satın al
https://takipcikenti.com
https://ucsatinal.org
instagram takipçi satın al
https://perdemodelleri.org
https://yazanadam.com
instagram takipçi satın al
balon perdeler
petek üstü perde
mutfak tül modelleri
kısa perde modelleri
fon perde modelleri
tül perde modelleri
https://atakanmedya.com
https://fatihmedya.com
https://smmpaketleri.com
https://takipcialdim.com
https://yazanadam.com
yasaklı sitelere giriş
aşk kitapları
yabancı şarkılar
sigorta sorgula
https://cozumlec.com
word indir ücretsiz
tiktok jeton hilesi
rastgele görüntülü sohbet
erkek spor ayakkabı
fitness moves
gym workouts
https://marsbahiscasino.org
http://4mcafee.com
http://paydayloansonlineare.com

BESTSITE 提到...

Interesting stuff to read. Keep it up. This is very informative and interesting for those who are interested in blogging field.

야한동영상

CLICKME 提到...

"Undeniably imagine that which you stated. Your favorite reason seemed to be at the net the easiest factor to take note of. I say to you, I definitely get irked at the same time as people consider issues that they just do not recognize about. You controlled to hit the nail upon the highest and also defined out the entire thing with no need side effect, other people can take a signal. Will likely be again to get more. Thank you 오피"

MY SITE 提到...

Enjoyed reading the article above , really explains everything in detail, the article is very interesting and effective. Thank you and good luck for the upcoming articles.

외국인출장

magosucomwep 提到...

If your are facing problem to activate Youtube on device or TV, Go to youtube.com/activate site and enter 8- digit verification confirmation code & proceed.
사설경마

magosucowep

Majortotosite Pro 提到...

Thanks for such a great post and the review, I am totally impressed! Keep stuff like this coming. 메이저사이트

Racesite Pro 提到...

I have a hard time describing my thoughts on content, but I really felt I should here. Your article is really great. I like the way you wrote this information
온라인경마
경마사이트


Oncasinosite Net 提到...

It was my excitement discovering your site last night. I came here now hoping to find out interesting things. I was not dissatisfied. Your ideas for new methods on this subject were useful and an excellent help to myself. 바카라사이트

uillyacfabian 提到...

Stilletto Titanium Hammer Stainless Steel-Plated Double Edge
Stilletto Titanium Hammer titanium price Stainless Steel-Plated Double Edge Razor Blade · 4”- Sterling sia titanium stainless titanium gravel bike steel, 4-Piece, 3.0 titanium white acrylic paint oz., 10 titanium pots and pans

Royalcasino887 提到...

Royalcasino887

匿名 提到...

he648 louis vuitton outlet,louis vuitton outlet,louis vuitton outlet,louis vuitton outlet,louis vuitton outlet,louis vuitton outlet dq592

張貼留言