2016-05-20 37 views
3

私はjqxGridを持っていて、それに何らかのオブジェクトを設定する必要があります。オブジェクトは完全にランダムであり、一部のデータフィールドが空である可能性があります。そのデータがそのオブジェクトに存在する場合にのみ、特定のcoloumnを表示する必要があります。例えばのためのjqxGridで動的な列を作成する方法jquery


columns: [ 
       { text: 'Application Id', filtertype: 'input', datafield: 'ApplicationId', cellsrenderer: AppIdRenderer, width: appId }, 
       { text: 'Name', columntype: 'textbox', filtertype: 'input', datafield: 'ApplicantName', width: Applicant }, 
       { text: 'Submitted Date', datafield: 'SubmitDate', filtertype: 'date', cellsalign: 'left', cellsformat: 'dd/MM/yyyy', width: ApplDate }, 
       { text: 'Last Action', datafield: 'LastActionDate', filtertype: 'date', cellsalign: 'left', cellsformat: 'dd/MM/yyyy', width: ApplDate }, 
       { text: 'University', columntype: 'textbox', filtertype: 'checkedlist', datafield: 'AppType', width: UTYApplied }, 
       { text: 'Course Applied', columntype: 'textbox', filtertype: 'checkedlist', datafield: 'AppliedCourse', width: ApplCourse }, 
       { text: 'Latest Comments', columntype: 'textbox', filtertype: 'input', datafield: 'LatestComments', width: ApplCourse }, 
       { text: 'AppStatus', datafield: 'AppStatus' }, 
       { text: 'Status', columntype: 'textbox', filtertype: 'checkedlist', datafield: 'Status', width: ApplCourse } 
] 

:私は、データフィールド "LatestComments" が発生した場合にのみcoloumn "LatestComments" を示す必要があります。

答えて

2

jqxGrid(ローカルデータソース、リモートデータソース)の使い方については、ほとんど書きません。これは、ソリューションを提案する上で不可欠な場合があります。

すべて行の特定のデータフィールドが完全に定義されていないか、特にデータが入力されているかどうかに応じて、列全体を非表示にするか表示するかを選択します。

これを行うには、データを処理してそのような状況をチェックする必要があります(すべての行をループし、少なくともデータフィールドにデータが含まれているかどうかを確認してください)。次に、bindingcompleteコールバックで、すべての列をループし、showcolumnまたはhidecolumnのいずれかを適用します。

+0

提案のための@baderaありがとうございました:) –

関連する問題