Guest User

Untitled

a guest
Jun 18th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. {"Result" : [
  2. {
  3. "Id" : "5214",
  4. "ParentReasonId" : "0",
  5. "Description" : "Billing & Payment",
  6. "SysName" : "Billing & Payment",
  7. "SysCategory" : "Billing & Payment",
  8. "ClientId" : "924",
  9. "DispositionCount" : "6",
  10. "IsActive" : true,
  11. "ChildReasonCount" : "8",
  12. "Attributes" : [],
  13. "SortOrder" : "0",
  14. "CreatedBy" : null
  15. }
  16. ]
  17. }
  18.  
  19. jQuery("#chained_child").cascade("#chained", {
  20. ajax: { url: 'Customhandler.ashx?List=MyList' },
  21. template: commonTemplate,
  22. match: commonMatch
  23. });
  24.  
  25. function commonTemplate(item) {
  26. return "<option Value='" + item.Result.Id + "'>"
  27. + item.Result.Description + "</option>";
  28. };
  29.  
  30. item.Result[0].Id
  31.  
  32. {
  33. "Result" :
  34. {
  35. "Id" : "5214",
  36. "ParentReasonId" : "0",
  37. "Description" : "Billing & Payment",
  38. "SysName" : "Billing & Payment",
  39. "SysCategory" : "Billing & Payment",
  40. "ClientId" : "924",
  41. "DispositionCount" : "6",
  42. "IsActive" : true,
  43. "ChildReasonCount" : "8",
  44. "Attributes" : [],
  45. "SortOrder" : "0",
  46. "CreatedBy" : null
  47. }
  48. }
  49.  
  50. [
  51. {
  52. "Result" :
  53. {
  54. "Id" : "5214",
  55. "ParentReasonId" : "0",
  56. "Description" : "Billing & Payment",
  57. "SysName" : "Billing & Payment",
  58. "SysCategory" : "Billing & Payment",
  59. "ClientId" : "924",
  60. "DispositionCount" : "6",
  61. "IsActive" : true,
  62. "ChildReasonCount" : "8",
  63. "Attributes" : [],
  64. "SortOrder" : "0",
  65. "CreatedBy" : null
  66. }
  67. }
  68. ]
  69.  
  70. $(function(){
  71. $('#chained_child').cascade(
  72. '#chained',
  73. {
  74. ajax: {
  75. url: 'Customhandler.ashx?List=MyList',
  76. dataFilter: extractResult
  77. },
  78. template: customTemplate,
  79. match: customMatch
  80. }
  81. );
  82.  
  83. function extractResult(data) {
  84. return eval('(' + data + ')').Result;
  85. }
  86.  
  87. function customTemplate(item) {
  88. return $('<option />')
  89. .val(item.Id)
  90. .text(item.Description);
  91. }
  92.  
  93. function customMatch(selectedValue) {
  94. return this.ParentReasonId == selectedValue;
  95. }
  96. });
Add Comment
Please, Sign In to add comment